1
0
Fork 0
mirror of https://github.com/activerecord-hackery/ransack.git synced 2022-11-09 13:47:45 -05:00

Make search_form_for's default :as option respect custom search_key

Fixes #92
This commit is contained in:
Robert Speicher 2014-11-15 14:56:19 -05:00
parent 64e13436e6
commit c3a9110e24
2 changed files with 12 additions and 1 deletions

View file

@ -28,7 +28,7 @@ module Ransack
"#{search.klass.to_s.underscore}_search",
:method => :get
}
options[:as] ||= Ransack::Constants::DEFAULT_SEARCH_KEY
options[:as] ||= Ransack.options[:search_key]
options[:html].reverse_merge!(html_options)
options[:builder] ||= FormBuilder

View file

@ -301,6 +301,17 @@ module Ransack
it { should match /action="\/people.json"/ }
end
describe '#search_form_for with custom default search key' do
before do
Ransack.configure { |c| c.search_key = :example }
end
subject {
@controller.view_context
.search_form_for(Person.search) { |f| f.text_field :name_eq }
}
it { should match /example_name_eq/ }
end
end
end
end