Ok this seems a very common problem, but looking online I can't seem to find a solution for my example.
When trying to update an object(product) using the below code I get the undefined method `stringify_keys' for "4":String NoMethod error page thrown back by Rails.
Here is the code to see if you can point out what I'm doing wrong:
Product Controller
def update
@product = Product.find(params[:id])
if @product.update(params[:id])
redirect_to @product
else
render 'edit'
end
end
The edit form View:
<%= form_for(@product.id) do |f| %>
<% end %>
<div class="field">
<%= f.label :name %><br>
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :price %><br>
<%= f.text_field :price %>
</div>
<div class="field">
<%= f.label :descriptio %><br>
<%= f.text_field :description %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
I'm hoping I can get this to work!
if @product.update(params[:id])is wrong.It should beif @product.update(params[:product])@product.update_attributes(params[:product])