search for: beutiful

Displaying 1 result from an estimated 1 matches for "beutiful".

Did you mean: beautiful
2006 Aug 19
3
Special ruby language for describing sql conditions
...way to define conditions in an sql query, when the numbers of attributes increase, so does the uglyness. So instead of passing a hash, I thought you could specify the conditions directly in code. I hacked together some example code which actually turned out to work. The result is concise and pretty beutiful. def search(params) Ad.find(:all) do |conditions| conditions.area_id = params[:area_id] if params[:area_id] && params[:area_id].to_i > 0 conditions.kind = params[:kind] if params[:kind] conditions.selling = params[:selling] || 1 conditions.approved > 1 condition...