Hi there, I am working through a tutorial and I''m at the point of accepting or declining a friend request. However, whenever I click accept of decline, I get the following error: Mysql::Error: Column ''created_at'' in order clause is ambiguous: SELECT `users`.id FROM `users` INNER JOIN `friendships` ON `users`.id `friendships`.friend_id WHERE (`users`.`id` = 115) AND ((`friendships`.user_id = 114) AND ((status = ''requested''))) ORDER BY created_at LIMIT 1 I''ve looked through the controller for these 2 actions, but nothing stands out. Please can anyone suggest how to fix this? Many Thanks -- 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 Nov 29, 12:37 pm, RubyonRails_newbie <craigwest...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi there, I am working through a tutorial and I''m at the point of > accepting or declining a friend request. > > However, whenever I click accept of decline, I get the following > error: > > Mysql::Error: Column ''created_at'' in order clause is ambiguous: SELECT > `users`.id FROM `users` INNER JOIN `friendships` ON `users`.id > `friendships`.friend_id WHERE (`users`.`id` = 115) AND > ((`friendships`.user_id = 114) AND ((status = ''requested''))) ORDER BY > created_at LIMIT 1 > > I''ve looked through the controller for these 2 actions, but nothing > stands out. > > Please can anyone suggest how to fix this? > > Many ThanksEither in your User has_many :friendships declaration or the User.find that joins :friendships in the controller you have :order => "created_at". The RDBMS can''t know which table to use for created_at column, as both have one. You need to specify that. -- 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.
makes sense i think, but how would i specify it? On 29 Nov, 18:04, pharrington <xenogene...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Nov 29, 12:37 pm, RubyonRails_newbie <craigwest...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > > > > > > > Hi there, I am working through a tutorial and I''m at the point of > > accepting or declining a friend request. > > > However, whenever I click accept of decline, I get the following > > error: > > > Mysql::Error: Column ''created_at'' in order clause is ambiguous: SELECT > > `users`.id FROM `users` INNER JOIN `friendships` ON `users`.id > > `friendships`.friend_id WHERE (`users`.`id` = 115) AND > > ((`friendships`.user_id = 114) AND ((status = ''requested''))) ORDER BY > > created_at LIMIT 1 > > > I''ve looked through the controller for these 2 actions, but nothing > > stands out. > > > Please can anyone suggest how to fix this? > > > Many Thanks > > Either in your User has_many :friendships declaration or the User.find > that joins :friendships in the controller you have :order => > "created_at". The RDBMS can''t know which table to use for created_at > column, as both have one. You need to specify that.-- 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.
Actually, for now - commenting the :order out in User.rb seems to allow me to continue without issue. :-) thanks for the advice - it made me look in the right direction. On 29 Nov, 18:06, RubyonRails_newbie <craigwest...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> makes sense i think, but how would i specify it? > > On 29 Nov, 18:04, pharrington <xenogene...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Nov 29, 12:37 pm, RubyonRails_newbie <craigwest...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > > wrote: > > > > Hi there, I am working through a tutorial and I''m at the point of > > > accepting or declining a friend request. > > > > However, whenever I click accept of decline, I get the following > > > error: > > > > Mysql::Error: Column ''created_at'' in order clause is ambiguous: SELECT > > > `users`.id FROM `users` INNER JOIN `friendships` ON `users`.id > > > `friendships`.friend_id WHERE (`users`.`id` = 115) AND > > > ((`friendships`.user_id = 114) AND ((status = ''requested''))) ORDER BY > > > created_at LIMIT 1 > > > > I''ve looked through the controller for these 2 actions, but nothing > > > stands out. > > > > Please can anyone suggest how to fix this? > > > > Many Thanks > > > Either in your User has_many :friendships declaration or the User.find > > that joins :friendships in the controller you have :order => > > "created_at". The RDBMS can''t know which table to use for created_at > > column, as both have one. You need to specify that.-- 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 Sun, 2009-11-29 at 10:06 -0800, RubyonRails_newbie wrote:> makes sense i think, but how would i specify it? > > On 29 Nov, 18:04, pharrington <xenogene...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On Nov 29, 12:37 pm, RubyonRails_newbie <craigwest...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > > wrote: > > > > > > > > > > > > > Hi there, I am working through a tutorial and I''m at the point of > > > accepting or declining a friend request. > > > > > However, whenever I click accept of decline, I get the following > > > error: > > > > > Mysql::Error: Column ''created_at'' in order clause is ambiguous: SELECT > > > `users`.id FROM `users` INNER JOIN `friendships` ON `users`.id > > > `friendships`.friend_id WHERE (`users`.`id` = 115) AND > > > ((`friendships`.user_id = 114) AND ((status = ''requested''))) ORDER BY > > > created_at LIMIT 1 > > > > > I''ve looked through the controller for these 2 actions, but nothing > > > stands out. > > > > > Please can anyone suggest how to fix this? > > > > > Many Thanks > > > > Either in your User has_many :friendships declaration or the User.find > > that joins :friendships in the controller you have :order => > > "created_at". The RDBMS can''t know which table to use for created_at > > column, as both have one. You need to specify that.---- :order => ''users.created_at'' (or ''friendships.created_at'' depending upon which order you wanted...like mysql, I can''t know which one you want) Craig -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- 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.
This is an error in the SQL statement being generated. The created_at column exists in both the Users and Friendships tables. You need to indicate the table of the column you want to order by. Example: ".... ORDER BY users.created_at LIMIT 1" On Nov 29, 9:37 am, RubyonRails_newbie <craigwest...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi there, I am working through a tutorial and I''m at the point of > accepting or declining a friend request. > > However, whenever I click accept of decline, I get the following > error: > > Mysql::Error: Column ''created_at'' in order clause is ambiguous: SELECT > `users`.id FROM `users` INNER JOIN `friendships` ON `users`.id > `friendships`.friend_id WHERE (`users`.`id` = 115) AND > ((`friendships`.user_id = 114) AND ((status = ''requested''))) ORDER BY > created_at LIMIT 1 > > I''ve looked through the controller for these 2 actions, but nothing > stands out. > > Please can anyone suggest how to fix this? > > Many Thanks-- 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.