Trying various things here to eliminate this problem. In my dyanmic
search ,
if no search criteria is selected then all records are returned. It’s
not
what I want. By the way this is an observe_form. Help is greatly
appreciated.
Here is the controller -
def list
category_id = params[:category_id]
state_id = params[:state_id]
term_id = params[:term_id]
city = params[:city]
title = params[:title]
pq = Position.query # I'm using the plugin CriteriaQuery
pq.category_id_in(params[:category_id])
unless(params[:category_id]|| “”).empty?
pq.state_id_in(params[:state_id]) unless(params[:state_id]||
“”).empty?
pq.term_id_in(params[:term_id]) unless(params[:term_id]||
“”).empty?
pq.city_in(params[:city].split(",")) unless(params[:city]||
“”).empty?
pq.title_in(params[:title].split(“,”)) unless(params[:title]||
“”).empty?
pp pq
@positions = pq.find
render :partial => "positions_list", :layout => false
end
end
Here is the observe_form:# in the possibility that I can somehow enforce
it
here to not return any records in the event nothing is selected
# I’m also showing my partial down
below
<%= observe_form “asearch”,
:frequency => 0.5,
:update => ‘table’,
:before => “Element.show(‘roller’)”,
:success => “Element.hide(‘roller’)”,
:url => ‘list’ %>
Partial:
<% if @positions == nil %>
<%="Enter search criteria"%>
<% elsif @positions.size == 0 %><%="No jobs found using current search criteria"%>
<% else %> <% @positions.each do |p| %> "> <% end %>Title | Category | Location | Terms |
<%= p.title %> | <%= p.category.name %> | <%= p.city %>-<%= p.state.name %> | <%= p.term.name %> |
–