0
У меня есть вложенный маршрут, но я получаю ошибку в отсутствии необходимых ключей: [: product_id]. Я передаю это с помощью метода link_to, хотя это, кажется, не работаетUrlGenerationError в пределах маршрутов
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 Шаблон
- 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",
МАРШРУТЫ
namespace :admin do
namespace :merchandise do
resources :products do
member do
get :add_properties
put :activate
end
resources :variants
end
Не могли бы вы поделиться своим 'config/routes.rb'? – oreoluwa
@oreoluwa добавил маршруты, надеюсь, это поможет –
Что происходит, когда вы удаляете '@ variant' из' form_for'? – oreoluwa