Administrate: ArgumentError in `application/_collection.html.erb`

Created on 24 Oct 2019  路  6Comments  路  Source: thoughtbot/administrate

  • What were you trying to do?
  • version 0.10.0 works fine
  • Upgrade to version 0.11.0
  • Start server
  • Browse to /admin

  • What did you end up with (logs, or, even better, example apps are great!)?
    ``=> Booting Puma => Rails 5.2.3 application starting in development => Runrails server -h` for more startup options
    [60856] Puma starting in cluster mode...
    [60856] * Version 3.12.0 (ruby 2.6.5-p114), codename: Llamas in Pajamas
    [60856] * Min threads: 2, max threads: 2
    [60856] * Environment: development
    [60856] * Process workers: 1
    [60856] * Preloading application
    [60856] * Listening on tcp://localhost:3000
    [60856] Use Ctrl-C to stop
    [60856] - Worker 0 (pid: 60859) booted, phase: 0
    Started GET "/admin" for ::1 at 2019-10-23 15:59:16 -0700
    (3.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
    Processing by Admin::UsersController#index as HTML
    User Load (7.8ms) SELECT "users".* FROM "users" WHERE "users"."deleted" = $1 AND "users"."id" = $2 LIMIT $3 [["deleted", false], ["id", 1], ["LIMIT", 1]]
    Rendering admin/application/index.html.erb within layouts/administrate/application
    Rendered /Users/kimball/.rvm/gems/ruby-2.6.5@selfdetermine/gems/administrate-0.11.0/app/views/administrate/application/_search.html.erb (2.8ms)
    Rendered admin/application/_collection.html.erb (3.9ms)
    Rendered admin/application/index.html.erb within layouts/administrate/application (75.9ms)
    Completed 500 Internal Server Error in 262ms (ActiveRecord: 28.9ms)

ActionView::Template::Error (wrong number of arguments (given 0, expected 2)):
28: scope="col"
29: role="columnheader"
30: aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>">
31: <%= link_to(sanitized_order_params.merge(
32: collection_presenter.order_params_for(attr_name)
33: )) do %>
34: <%= t(

app/views/admin/application/_collection.html.erb:31:in block in _app_views_admin_application__collection_html_erb___2843941576294046178_70236531166900' app/views/admin/application/_collection.html.erb:24:ineach'
app/views/admin/application/_collection.html.erb:24:in _app_views_admin_application__collection_html_erb___2843941576294046178_70236531166900' app/views/admin/application/index.html.erb:56:in_app_views_admin_application_index_html_erb__913962786711478029_70236497377300'
```

error location: https://github.com/thoughtbot/administrate/blob/master/app/views/administrate/application/_collection.html.erb#L31

  • What versions are you running?

    • Rails
      5.2.3

    • administrate
      0.11.0

bug install views-and-styles

All 6 comments

Regenerate your custom views in new administrate version:

rails generate administrate:views

I think this is fixed now. Closing.

Hi I am facing a similar issue, i am on rails 5.2.3. can you please share the fix?

@aksharj - are you using custom views? If not, could you please share the error you see?

Hi @pablobm, sorry for a late reply, yes i am using custom view. the error i am seeing is as follows

wrong number of arguments (given 0, expected 2) excluded from capture: DSN not set

ActionView::Template::Error (wrong number of arguments (given 0, expected 2)):
    28:         scope="col"
    29:         role="columnheader"
    30:         aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>">
    31:         <%= link_to(sanitized_order_params.merge(
    32:           collection_presenter.order_params_for(attr_name)
    33:         )) do %>
    34:         <%= t(

app/views/admin/users/_collection.html.erb:31:in `block in _app_views_admin_users__collection_html_erb__1719289249485665225_70321659238580'
app/views/admin/users/_collection.html.erb:24:in `each'
app/views/admin/users/_collection.html.erb:24:in `_app_views_admin_users__collection_html_erb__1719289249485665225_70321659238580'
app/views/admin/application/index.html.erb:56:in `_app_views_admin_application_index_html_erb___3549165793792612575_70321573278520'
app/controllers/admin/users_controller.rb:6:in `index'

I was previously on version 0.10.0 and updated to 0.14.0 and this is when i started seeing the error.

The issue is that sanitized_order_params now takes two arguments. This is what the official _collection template looks like now around this section:

https://github.com/thoughtbot/administrate/blob/64aaa98a79b3108fb1442025eb818d3aea8e7b3d/app/views/administrate/application/_collection.html.erb#L28-L34

To fix this you'll have to adapt your custom template to incorporate these changes. One way to do this is to re-run the views generator (rails generate administrate:views) and then compare the changes with your own changes and try to integrate them together.

Was this page helpful?
0 / 5 - 0 ratings