Developing a sql where clause in ror
I have a search form with firstname, lastname, city, postalcode, telephone, etc. One, some or all of the fields must be filled in and that means that I need to create a dynamic where clause and I suppose the best way is to use conditions like
. I am going to use the find_by_sql method because the statement is quite involved to collect all the information that I need.
Post.find_by_sql ["SELECT * FROM posts WHERE author = ? AND created > ?", author_id, start_date]
Can anyone point me to an example or tutorial on how to create a string, array or hash that would work for my example. It seems as though this would be a simple task but I can find very little by way of examples on the web and I have exhausted my attempts at success. What I need is someone to enlighten me with a blinding glimpse of the obvious.