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:
parent
64e13436e6
commit
c3a9110e24
2 changed files with 12 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue