In my form i have a lot of fields, and when i submit my form im my url i see a lot of empty params, like url?a=&b=&c= and my has_scope model think that i want to use this params, but with null value, but this is wrong.
Part of my model and controller:
class CarsController < ApplicationController
has_scope :by_manufacturer
has_scope :by_price, :using => [:price_from, :price_to]
end
class Car < ActiveRecord::Base
scope :by_manufacturer, -> vehicle_manufacturer_id { where(:vehicle_manufacturer_id => vehicle_manufacturer_id) }
scope :by_price, -> price_from, price_to { where("price >= ? AND price <= ?", price_from, price_to) }
end
How could i write something like:
if vehicle_manufacturer_id.present?
has_scope :by_manufacturer
end
how is it right to check on field presense? And where to write in and how?