Monday, November 26, 2007

Office Remodel

So here I sit in a random cube across the office from where I usually work. The cube is a little different than what I am used to. My really old office used to be in a computer lab and when I transfered from UW-Stout to UW-Eau Claire we were working a room in the basement of one of the buildings. Then we got moved to a large cube were all of the students work in another building. In our new diggs they decided to build a wall now so we are scattered throughout the entire office area in random cubes. It's not bad working on my laptop because I am mobile, everyone else is crammed into one regular cube which is way to hot for me.

I have been working on a housing listing site and just started to implement the advanced search feature. I found that I had not handled all the edge cases in my tests. Have no fear its up and working and of course I have some code to show you.

Here it is:

def = {})

composed_cond =

cond_number_of_bedrooms = :properties do
number_of_bedrooms == params[:search][:number_of_bedrooms]

cond_min_price = :properties do
if !params[:search][:min_price].blank?
price >= params[:search][:min_price]

cond_max_price = :properties do
if !params[:search][:max_price].blank?
price <= params[:search][:max_price]

composed_cond << cond_number_of_bedrooms
composed_cond << cond_min_price
composed_cond << cond_max_price

@properties = Property.find(:all,
:include =>[:amenities, :utilities],
:conditions => composed_cond.to_sql)


No comments: