I want to make a SQL query in a Rails app that adds a condition when a drop-down menu is added. Obviously I don't want to search with a blank condition if the drop down is not selected. How can I develop a dynamic condition in an SQL statement?
untested example:
When dropdown is not selected: Object.find("billy," :conditions => {})
When dropdown is selected: Object.find("billy," :conditions => {"last_name => "johnson"})
Thank you for your input!