Я пытаюсь создать обзор в моем приложении, однако, когда я делаю следующее в моем контроллере:ActiveRecord :: RecordNotFound - продукт без ID
def create
@product = Product.find(params[:product_id])
@review = @product.reviews.create(params[:review])
redirect_to product_path(product)
end
я получаю Couldn't find Product without an ID
. Я заполняю форму, и некоторые, где вдоль линии, когда он не может показаться, это следующая строка @product = Product.find(params[:product_id])
, чтобы найти продукт
маршруты
resources :products do
resource :reviews
end
продукты/show.html.erb
<%= form_for(@product.reviews.build) do |f| %>
<div class="field">
<%= f.label :title %>
<br/>
<%= f.text_field :title %>
</div>
<div class="field">
<%= f.label :author %>
<br/>
<%= f.text_field :author %>
</div>
<div class="field">
<%= f.label :content %>
<br/>
<%= f.text_area :content %>
</div>
<div class="field">
<%= f.label :rating %>
<br/>
<%= f.number_field :rating %>
</div
<div class="actions">
<%= f.submit %>
</div>
<% end %>
Не могли бы вы выслать ваши параметры? Я считаю, что ваш метод 'params' не имеет ключа: product_id. – sergelerator