rubyonrailsin

A Ruby and Rails talk

Thursday, March 25, 2010


[Rails] Re: Order by an h_m_t association, pushing a value to the top

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

Amendment - the last thing i posted didn't quite work - the rest of them
(ie which didn't have banana) weren't sorted as i had the logic a bit
screwed up. This is better: instead of this:

:order => "(tags.name = 'banana' or tags.name) desc"

do this:

:order => "(tags.name = 'banana') desc, tags.name"

Which is *now* effectively the same as yours (it wasn't before). :)

cheers! max
--
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@googlegroups.com.
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.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive