Forum: Ruby on Rails find dynamic conditions ?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jamal S. (Guest)
on 2007-05-29 14:26
Hello there,

I have a little problem with the find, I want to put some conditions
depend on the users want.

if params[:l].to_i > 0
  find_options[:conditions] = ["language_id = ?", params[:l]]

if params[:c].to_i > 0
  find_options[:conditions] = ["category_id = ?", params[:c]]

@videos = VideoBrowse.find(:all, :conditions =>
find_options[:conditions] , :include => [:category, :language, :user])

Is there a better way to do it then this?

and thanks for help :D
This topic is locked and can not be replied to.