Topic: Problem when rendering a partial if :collections is nil (empty) !
I'm looking for a nice way of "not rendering" a partial if its collections is nil.
Let's take an example :
I have an itune like ajax application (with playlists name on the left and playlist details on the right).
To render the list of playlist, I use a partial (call it playlist_list) that consume a collection of playlists.
So, we have :
render(:partial => "playlist_list", :collection => @playlists).
If I have some playlist in my database (at least one) then everything works fine but, if @playlists is
empty, then it raises an error ...
-> What could be the best way to avoid this ?
-> use an if statement in the main view to see if @playlists is nil (if nil then I do not render otherwise I do render the partial)
(I don't think that the best solution ... logic in the view ... hum not very nice but is there another solution ???, like :conditions in the partial render ?)
Thanks for your help !!!