Hi to all,
I want to be able to put alias to my Song.find query.
the artist field belongs to song model so that i could code efficiently
in sorting columns. I want to put an (s) alias to my Song model.
In the code below :select => "artist, g.genre_name AS name_genre"
should be
:select => "s.artist, g.genre_name AS name_genre"
In my controller:
@q = Song.find(:all, :select => "artist, g.genre_name AS
name_genre",
:joins => "LEFT OUTER JOIN genres AS g on songs.genre_id = g.id",
:order
=> params[:sort])
In my view:
<th><%= link_to "Artist", :sort =>
"artist"%></th>
<th><%= link_to "Genre", :sort =>
"genre_name"%></th>
Anyone has an idea how to do this?
--
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-/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.