2016-06-14 11 views
0

Ich habe eine verschachtelte Route, aber ich erhalte den Fehler fehlende erforderliche Schlüssel: [: product_id]. Ich bin vorbei dies über die link_to Methode, obwohl es nichtUrlGenerationError in Routen

No route matches {:action=>"index", :controller=>"admin/merchandise/variants", :locale=>#<Product id: 7, name: "Latte", description: nil, product_keywords: [], product_type_id: 1, prototype_id: nil, permalink: "latte", available_at: nil, deleted_at: "2016-06-13 13:41:47", meta_keywords: "", meta_description: "", featured: false, description_markup: nil, brand_id: nil, created_at: "2016-06-13 13:41:47", updated_at: "2016-06-13 13:41:47">, :product_id=>#<Variant id: nil, product_id: 7, sku: nil, price: #<BigDecimal:7fb49c1cf540,'0.0',9(18)>, cost: #<BigDecimal:7fb49c1cf0b8,'0.0',9(18)>, master: false, deleted_at: nil, created_at: nil, updated_at: nil>} missing required keys: [:product_id] 

HAML Vorlage

- title "New Variant (#{@product.name})" 
= link_to "Back to Product", admin_merchandise_product_path(@product), class: 'button small' 
= form_for @variant, :url => admin_merchandise_product_variants_path(@product,@variant), :html => {:class => ''} do |form| 
    = render :partial => '/admin/merchandise/variants/form', :locals => {:form => form} 
    .generic_submit_button 
    = submit_tag "Create", 

WEGE

namespace :admin do 
namespace :merchandise do 
resources :products do 
      member do 
      get :add_properties 
      put :activate 
      end 
      resources :variants 
     end 
+0

Würden Sie Ihre 'config/routes.rb' teilen? – oreoluwa

+0

@oreoluwa hat die Routen hinzugefügt hoffentlich wird das helfen –

+1

Was passiert, wenn Sie die '@ Variante' aus der' Form_for' entfernen? – oreoluwa

Antwort

1

Ich denke, zu sein scheint arbeiten, sollten Sie die @variant aus dem entfernen form_for.