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.. def show_image @id = User.find(:all, :select => ''user.id'') for id in @id @image = ActiveRecord::Base.connection.select_value(''select image from Picture pic inner join Cultures c on pic.culture_id = c.id inner join user pt on pt.id = p.user where pt.id = "id"''); end send_data @image, :type => ''image/png'', :disposition => ''inline'' end and i get an error "(SQLite3::SQLException: ambiguous column name: id: " Please help and give me some advices.. Big thanks for all -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 <joanne0558-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 allWhy 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Jun 14, 2011 at 4:08 AM, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Amritpal, please stop posting several messages asking the same thing. >This is not my post -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thank you very much On Jun 14, 2011, at 4:08 AM, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 <joanne0558-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 14 June 2011 09:24, amritpal pathak <amritpalpathak1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, Jun 14, 2011 at 4:08 AM, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> Amritpal, please stop posting several messages asking the same thing. > > This is not my postOf course not.... I believe you (from your new email address...). I''m sorry. It doesn''t help when Joanne/Yennie keeps changing their display name with every posting.... you can understand our confusion (what with the four-or-more identities you post under, you must get very confused yourself :-/ -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.