Administrate: "ActionView::Template::Error: Please use symbols for polymorphic route arguments" on Rails 6.1.3.2

Created on 8 May 2021  路  2Comments  路  Source: thoughtbot/administrate

The issue looks the same reported here: ref issue.


  • What were you trying to do?

Opening any admin route.

  • What did you end up with (logs, or, even better, example apps are great!)?
2021-05-08 09:25:52 +0200: Rack app error handling request { GET /admin }
#<ActionView::Template::Error: Please use symbols for polymorphic route arguments.>
/Users/mat/.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/actionpack-6.1.3.2/lib/action_dispatch/routing/polymorphic_routes.rb:310:in `handle_list'
/Users/mat/.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/actionpack-6.1.3.2/lib/action_dispatch/routing/polymorphic_routes.rb:218:in `polymorphic_method'
/Users/mat/.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/actionpack-6.1.3.2/lib/action_dispatch/routing/polymorphic_routes.rb:139:in `polymorphic_path'
/Users/mat/.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/actionview-6.1.3.2/lib/action_view/routing_url_for.rb:102:in `url_for'
/Users/mat/.asdf/installs/ruby/2.6.6/lib/ruby/gems/2.6.0/gems/actionview-6.1.3.2/lib/action_view/helpers/url_helper.rb:202:in `link_to'
#...

I got the error from the CI initially and then tried locally, dummy app:
https://github.com/blocknotes/administrate_ransack/tree/master/spec/dummy
If you clone the repo and run bin/rails s (it's proxied by the dummy app).

  • What versions are you running?

    • Rails: 6.1.3.2 (but it could also affect 6.0.3.7)

    • administrate: 0.16

bug

All 2 comments

You need to update your views to take into account the symbols change, e.g.:

spec/dummy/app/views/admin/posts/index.html.erb: https://github.com/blocknotes/administrate_ransack/blob/5ca281bf7c91230c9f3c4e44a60a80a15b5b7260/spec/dummy/app/views/admin/posts/index.html.erb#L48-L50

[:new, namespace, page.resource_path],

Needs to become:

[:new, namespace, page.resource_path.to_sym],

(See: app/views/administrate/application/index.html.erb in https://github.com/thoughtbot/administrate/pull/1972/files)

Aw, you are right!
Thank you @nickcharlton - it solves my issue.
I hope that it will help someone else that falls in the same hole 馃槃

P.S. I tried to remove the "bug" tag (which is wrong at this point), but I can't.

Was this page helpful?
0 / 5 - 0 ratings