I'm making a rails application so that users can search a database of midi records and find midi files that correspond to the attributes that I've given them. For example, a user might enter data into an html form for a midi file with name = "blah" composer= "buh" and difficulty = "insane". This is all fine and well, except that I would like when the user enters no data for a field, that field is ignored when doing the select statement on the database. Right now this is what my select statement looks like:
@midis=Midi.where(:name => params[:midi][:name],
:style => params[:midi][:style],
:numparts => params[:midi][:numparts],
:composer=> params[:midi][:composer],
:difficulty => params[:midi[:difficulty])
This works as expected, but if for example he/she leaves :composer blank, the composer field should not considered at all. This is probably a simple syntax thing but i wasn't able to find any pages on it.
Thanks very much!