Thank you very much
On Jun 14, 2011, at 4:08 AM, Michael Pavling <[email protected]> wrote: > Amritpal, please stop posting several messages asking the same thing. > If you have more info to add, contribute to your original thread. > > On 14 June 2011 02:41, Yennie <[email protected]> wrote: >> Hi, >> I am writing this code in purpose that i can i select image from the >> picture table and i want to get all the user so i can loop through >> user1 , user2 .... >> >> and display the pic on bowers.. >> >> Please help and give me some advices.. Big thanks for all > > Why aren't you using the associations you have set up in your model to > loop pictures? > > Your table names seem all over the place: capital letters and singular > names... it's not going to help the Rails magic to work. > > If you just want an array of user ids: > @ids = User.find(:all).map(&:id) > > ...but I really doubt that your approach is the best one (or even a > good one). You should be doing something along the lines of: > > # controller code > @users = User.all > > # view code > @users.each do |user| > # you can render user name, etc here > user.albums.each do |album| > # access to album info here > album.pictures.each do |picture| > # some picture stuff here > end > end > end > > but... it may be best for you to take a moment, flick back to page 1 > of Agile Web Development With Rails, and work quietly through the > tutorial again. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

