I'm trying to do solr search based on the text entered by the user. Firts I've to check whether the entered text is store or brand or category. After checking that condition I want to display corresponding riesults which are in the MainNavigationUrls table using solr search. Here is the controller action. It is working fine if I enter any store and can get proper results. But it is not going inside brands loop if the storesearch is found nill. Please explain why it is not executing the second case.
def search_all
@storesearch=Site.search do
fulltext params[:text]
with(:multibrand,1)
end
if(@storesearch.nil?)
@brandsearch=Brand.search do
fulltext params[:text]
end
if(@brandssearch.nil?)
@itemcategorysearch=MainCategory.search do
fulltext params[:text]
end
@itemcategorysearch.results.each do |result|
@itemcategorysearch1=MainNavigationUrl.search do
with :main_categoty_id, result.id
with :department_id, params[:deptid].to_i
paginate :page=>params[:page], :per_page=>45
end
end
else
@brandsearch.results.each do |result|
@brandsearch1=MainNavigationUrl.search do
with :brand_id, result.id
with :department_id, params[:deptid].to_i
paginate :page=>params[:page], :per_page=>45
end
end
else
@storesearch.results.each do |result|
@storesearch1=MainNavigationUrl.search do
with :site_id, result.id
with :department_id, params[:deptid].to_i
paginate :page=>params[:page], :per_page=>45
end
end
end
end