On Saturday, October 24, 2009, Gleb Mazovetskiy <glex.spb / gmail.com> wrote:
> Is there a way to express this with associations?
>
>   ¨ÂóïîçÓïîç®æéîäßâùßóñ쨥Ñû
>   ¨ÂÅÌÅÃóïîç󮪬 óïîçßðìáùìéóôßòåìáôéïîóèéðó®ðìáùìéóôßé>   ¨ÂÒÏóïîçÉÎÎÅÊÏÉÎ óïîçßðìáùìéóôßòåìáôéïîóèéð>   ¨Âóïîçó®éä óïîçßðìáùìéóôßòåìáôéïîóèéðó®óïîçßé>   ¨ÂÈÅÒÅ óïîçßðìáùìéóôßòåìáôéïîóèéðó®ðìáùìéóôßéäÎ
> (#{@playlists.collect{|p| p.id}.join(',')})})
>

Something like this should work. Double-check the :joins option in the
Rails documentation. I might have it wrong.

playlist_ids = @playlists.collect{|p| p.id}
Song.find(:all,
  :conditions => ["song_playlists_relationships.playlist_id IN (?)",
playlist_ids],
  :joins => :song_playlist_relationships)


-- 
Sent via mobile.

-- 
Find me - http://www.smajn.net/social