Forum: Ruby on Rails find dynamic conditions ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E3513c4edd6810bb4b9914b58da2a2c3?d=identicon&s=25 Jamal Soueidan (jamal)
on 2007-05-29 12:26
Hello there,

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

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

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

@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.