My two goals:
1) display last 10 posts in reverse chronological order
2) link to the author without hitting the database 2n-1 times
These work:
def list
@post_pages, @posts = paginate :posts, :order => "created_at
DESC",
:per_page => 10
end
def list
@post_pages, @posts = paginate :posts, :per_page => 10, :include =>
:person
end
This doesn''t:
def list
@post_pages, @posts = paginate :posts, :order => "created_at
DESC",
:per_page => 10, :include => :person
end
I get a "Column ''created_at'' in order clause is
ambiguous" error. I''m
not sure but I thought it was be possible to order the posts and then
join the person table. Otherwise I will hit the database with each
post. Does anyone have a solution to this? Thanks in advance!
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On Sat, 2007-03-03 at 03:45 +0100, Taylor Strait wrote:> My two goals: > 1) display last 10 posts in reverse chronological order > 2) link to the author without hitting the database 2n-1 times > > These work: > def list > @post_pages, @posts = paginate :posts, :order => "created_at DESC", > :per_page => 10 > end > > def list > @post_pages, @posts = paginate :posts, :per_page => 10, :include => > :person > end > > This doesn''t: > def list > @post_pages, @posts = paginate :posts, :order => "created_at DESC", > :per_page => 10, :include => :person > end > > I get a "Column ''created_at'' in order clause is ambiguous" error. I''m > not sure but I thought it was be possible to order the posts and then > join the person table. Otherwise I will hit the database with each > post. Does anyone have a solution to this? Thanks in advance!---- def list @post_pages, @posts = paginate :posts, :order => ''posts.created_at DESC'' :per_page => 10, :include => :person end To clarify ambiguity with two tables that have the same column name, you clarify which table to which you are referring. Craig --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Worked great. Thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---