This is a fairly simple set of conditions for your request. You can also check searchlogic . This is awesome and frees you from writing a lot of SQL.
Set up several variables
position = "internship" min_hourly = 7 max_hourly = 18 start_weeks = 2..4
Then write the following code:
Student.find(:all, :conditions => ["seeking_position = ? AND min_hourly = ? AND max_hourly = ? AND start_weeks between ?", position, min_hourly, max_hourly, start_weeks])
In Rails 3 you can use the new where() function
Student.where(:seeking_position => position, :min_hourly => min_hourly, :max_hourly => max_hourly, :start_weeks => start_weeks)
source share