On 25 April 2010 02:01, Louis-Pierre Dahito <li...@ruby-forum.com> wrote:
> Hi guys!
>
> There's a problem I'm dealing with since 2 days now and I haven't quite
> figured out what's wrong in my code.
>
> Fetching records with the following command doesn't work:
>
> Comment.find :all, :joins => :story, :conditions => {:stories => {:id =>
> 1}}, :order => "created_at DESC"
>
> It gives me the following error message:
>
> ActiveRecord::StatementInvalid: SQLite3::SQLException: ambiguous column
> name: created_at:

That error is telling you everything you need to know - there is more
than one "created_at" column in your query's selected fields. So you
need to specify which one to use for the order:

  Comment.find :all, :joins => :story, :conditions => {:stories =>
{:id => 1}}, :order => "comments.created_at DESC"

Hope that helps.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to