error of "undefined method `each' for #<Picture:0x927dea0>"

hi all,

I have an error "undefined method `each' for #<Picture:0x927dea0>" what is that mean?

in my view [code]

<% @user.each do |p| %> <%= p.image %> <% end %>

[/code]

in controller [code]            @user=picture.all(      :joins => :culture,                   :conditions => (Album.joins(:description))).first

[/code]

plz give me some advance

you exectued people.all.first so the @user only has one picture object instead of an array of pictures

Simple. You get only one picture object (the first one) because you’re using .first method. Since you have only one object, you can’t iterate over it using the each loop. Get it?

Just use @user.image instead in the view :slight_smile:

Simple. You get only one picture object (the first one) because you’re using .first method. Since you have only one object, you can’t iterate over it using the each loop. Get it?

Just use @user.image instead in the view :slight_smile:

or remove the .first if you want to display all user images.

maybe it’s just me but i suggest you rename your variables. given the error you had

undefined method `each’ for #Picture:0x927dea0

it would be easier if you change @user to @pictures.

Thanks all. :D… and i have other question… when i take the image file (BLOD)… i cannot display it … do you have any idea… Please give me some advice… thanks …\

and i have other question..

If you have another question, please start another thread.

when i take the image file (BLOD).. i cannot display it .. do you have any idea... Please give me some advice.. thanks ....\

How do you 'take it'? What code are you using to display it, and what errors do you get?

i am have any error about the code… but i cannot show/ display picture on the screen