diff --git a/lib/ransack/helpers/form_helper.rb b/lib/ransack/helpers/form_helper.rb index 0565554c..108bb1ba 100644 --- a/lib/ransack/helpers/form_helper.rb +++ b/lib/ransack/helpers/form_helper.rb @@ -130,7 +130,7 @@ def name def url_options @params.merge( - @options.except(:class, :data).merge( + @options.except(:class, :data, :host).merge( @search.context.search_key => search_and_sort_params)) end diff --git a/spec/ransack/helpers/form_helper_spec.rb b/spec/ransack/helpers/form_helper_spec.rb index a798a67e..c031d9dc 100644 --- a/spec/ransack/helpers/form_helper_spec.rb +++ b/spec/ransack/helpers/form_helper_spec.rb @@ -770,6 +770,18 @@ module Helpers it { should_not match /people\?data%5Bturbo_action%5D=advance/ } end + describe "#sort_link with host option" do + subject { @controller.view_context + .sort_link( + [:main_app, Person.ransack(sorts: ['name desc'])], + :name, + host: 'foo', controller: 'people' + ) + } + it { should match /href="\/people\?q/ } + it { should_not match /href=".*foo/ } + end + describe '#search_form_for with default format' do subject { @controller.view_context .search_form_for(Person.ransack) {} }