Episode 73 resulting in error: undefined method `stringify_keys!' for "33":String

I’m working with a similar model in Episode 73, (my scenario is
editing multiple pictures for a product using attachment_fu).

And I’m getting an error when I try the technique suggested:

./views/admin/_form.rhtml

<% for picture in product.pictures %>
<% fields_for “product[picture_attributes][]”, picture do |
picture_form| %>
Title: <%= picture_form.text_field :title %>
<% end %>

./models/product.rb
def picture_attributes=(picture_attributes)
picture_attributes.each do |attributes|
pictures.build(attributes)
end
end

undefined method `stringify_keys!’ for “33”:String

Parameters: {“commit”=>“Edit”, “product”=>{“image_url”=>“shep.jpg”,
“price”=>“400.00”, “title”=>“German Shepard Lab Mix #2b”,
“category_ids”=>[“6”],
“picture_attributes”=>{“33”=>{“title”=>“asdf2”},
“24”=>{“title”=>“asdf”}, “27”=>{“title”=>“asdf”},
“30”=>{“title”=>“asdf”}}, “description”=>“3 year old german shepard
lab mix. Test!”}, “id”=>“23”, “picture”=>{“uploaded_data”=>""}}

I noticed in the video, it shows the “picture_attributes” parameter as
an array (not a hash is it shows on mine).

Hello,

Am Montag, 31. Dezember 2007 schrieb chovy:

    Title: <%= picture_form.text_field :title %>

<% end %>

Try <%= picture_form.text_field :title, :index=> nil %>
as suggested in the episode.

Keep smiling
yanosz

On Dec 31, 3:52 am, chovy [email protected] wrote:

    Title: <%= picture_form.text_field :title %>

Parameters: {“commit”=>“Edit”, “product”=>{“image_url”=>“shep.jpg”,
“price”=>“400.00”, “title”=>“German Shepard Lab Mix #2b”,
“category_ids”=>[“6”],
“picture_attributes”=>{“33”=>{“title”=>“asdf2”},
“24”=>{“title”=>“asdf”}, “27”=>{“title”=>“asdf”},
“30”=>{“title”=>“asdf”}}, “description”=>“3 year old german shepard
lab mix. Test!”}, “id”=>“23”, “picture”=>{“uploaded_data”=>""}}

I noticed in the video, it shows the “picture_attributes” parameter as
an array (not a hash is it shows on mine).

Nevermind, episode #75 had the solution :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs