Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update app/controllers/rails_admin/main_controller.rb #1382

Merged
merged 2 commits into from

3 participants

@elsupergomez

Use Kaminari.config.param_name for personalized param name
This is useful for translate the param view in url an make rails_admin consistency with Kaminari configuration

@elsupergomez elsupergomez Update app/controllers/rails_admin/main_controller.rb
Use Kaminari.config.param_name for personalization of param name
This is usufull for traslate the param view in url
c7b1cd4
@mshibuya
Collaborator

Could you write specs for this change?

@elsupergomez

I can try

@bbenezech
Collaborator

@elsupergomez Can you check the failures at https://travis-ci.org/sferik/rails_admin/jobs/3031123 ?

Please note that spec are run in random order, so the failures may not be related to the environment.

@bbenezech bbenezech merged commit 26e797e into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 1, 2012
  1. @elsupergomez

    Update app/controllers/rails_admin/main_controller.rb

    elsupergomez authored
    Use Kaminari.config.param_name for personalization of param name
    This is usufull for traslate the param view in url
Commits on Nov 2, 2012
  1. @elsupergomez

    Update spec/controllers/main_controller_spec.rb

    elsupergomez authored
    Add spec for kaminari custom param_name
This page is out of date. Refresh to see the latest.
View
2  app/controllers/rails_admin/main_controller.rb
@@ -130,7 +130,7 @@ def check_for_cancel
def get_collection(model_config, scope, pagination)
associations = model_config.list.fields.select {|f| f.type == :belongs_to_association && !f.polymorphic? }.map {|f| f.association[:name] }
options = {}
- options = options.merge(:page => (params[:page] || 1).to_i, :per => (params[:per] || model_config.list.items_per_page)) if pagination
+ options = options.merge(:page => (params[Kaminari.config.param_name] || 1).to_i, :per => (params[:per] || model_config.list.items_per_page)) if pagination
options = options.merge(:include => associations) unless associations.blank?
options = options.merge(get_sort_hash(model_config))
options = options.merge(:query => params[:query]) if params[:query].present?
View
13 spec/controllers/main_controller_spec.rb
@@ -61,6 +61,19 @@
end
end
+ describe "#list_entries called from view with kaminari custom param_name" do
+ before do
+ @teams = 21.times.map { FactoryGirl.create :team }
+ controller.params = { :model_name => "teams" }
+ Kaminari.config.param_name = :pagina
+ end
+
+ it "paginates" do
+ expect(controller.list_entries(RailsAdmin.config(Team), :index, nil, false).to_a.length).to eq(21)
+ expect(controller.list_entries(RailsAdmin.config(Team), :index, nil, true).to_a.length).to eq(20)
+ end
+ end
+
describe "#list_entries called with bulk_ids" do
before do
@teams = 21.times.map { FactoryGirl.create :team }
Something went wrong with that request. Please try again.