I''m of course a Ruby noob, but not only that I''m a programing
noob, so
I think I would have this problem no matter what language I''m working
with. I''m trying to do a search for my website and can do listings of
properties no problem but I''m having a huge problem when trying to do
a search. I''ve been reading RailsSpace by Hartl and Prochazka which
is a great book and has gotten me a long way in learning Ruby and
programing but here is my problem. I am trying to use a default
search for ALL cities that match the criteria. When it defaults to a
city or someone chooses a city the search works fine, but it''s the ALL
cities options that is giving me fits. Here is the code I''m working
with. Any help would be greatly appreciated:
Property Model:
-----------------------------------------------
def self.find_by_pcc(params)
where = []
unless params[:mls].blank?
where << "mls = :mls"
end
unless params[:category].blank?
where << "category = :category"
end
unless params[:bedroom].blank?
where << "bedroom >= :bedroom"
end
unless params[:bathroom].blank?
where << "bathroom >= :bathroom"
end
unless params[:min_price].blank?
where << "price >= :min_price"
end
unless params[:max_price].blank?
where << "price <= :max_price"
end
unless params[:school].blank?
where << "school >= :school"
end
where << "city = :city"
if where.empty?
[]
else
find(:all,
:conditions => [where.join(" AND "), params],
:order => "city")
end
end
Controller:
-------------------------------------------------
def browse
@PropCategories =
[[''Residential'',''Residential''],
[''Commercial'',''Commercial''],[''Land'',''Land''],[''Rental'',''Rental'']]
@PropCities = [[''All Cities'',
'':all''],[''Bassfield'',
''Bassfield''],
[''Yada'',''Yada''],
[''Heidelberg'',''Heidelberg'']]
@PropSchools =
[[''Any'',''nil''],[''test'',''test''],[''alpha'',''alpha''],
[''beta'',''beta'']]
@title = "Browse"
return if params[:commit].nil?
@properties = Property.find_by_pcc(params)
else
render(:action => ''property_table'')
end
end
View:
------------------------------------------------------
<label for "city">City:</label>
<%= select "city", params[:city],@PropCities %>
Right now I don''t get an error, I just get a blank screen. Any help
or advice would be greatly appreciated.
Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---