I've recently upgraded to Rails 5.1.5 and running Administrate
gem 'administrate', '~> 0.9.0', git: 'https://github.com/thoughtbot/administrate.git', branch: 'master'
My Administrate sidebar is not rendering and displays the error:
NoMethodError - undefined method `to_model' for #<Administrate::Namespace::Resource:0x00007fdd3e303338>
It occurs in the link_to function at [namespace, resource]. Should this be [namespace, @resource]??
_sidebar.html.erb
<%= link_to(
display_resource_name(resource),
[namespace, resource],
class: "sidebar__link sidebar__link--#{nav_link_state(resource)}"
) %>
Potentially!
I've not heard of this issue elsewhere yet, do you have a sample application I could try out and replicate with?
Replace with
```.erb
<%= link_to(
display_resource_name(resource),
[namespace, resource_index_route_key(resource)],
class: "navigation__link navigation__link--#{nav_link_state(resource)}"
) %>
```
@minimul, do you think you'd be able to open a PR with this?
I'm still not quite sure how this was happening, so if you'd be able to explain that, that'd be great too!
This is just an edge case customization upgrade issue.
To reproduce one would have had previously ran rails g administrate:views:layout when app/views/admin/application/_sidebar.html.erb was referenced via app/views/layouts/admin/application.html.erb.
Of course app/views/admin/application/_navigation.html.erb has now taken the place of _sidebar.html.erb.
What I've done since and would be the proper approach is to re-run rails g administrate:views:layout and merge ones customizations with the latest Administrate layouts.
Personally, I'd just close this issue.
Most helpful comment
This is just an edge case customization upgrade issue.
To reproduce one would have had previously ran
rails g administrate:views:layoutwhenapp/views/admin/application/_sidebar.html.erbwas referenced viaapp/views/layouts/admin/application.html.erb.Of course
app/views/admin/application/_navigation.html.erbhas now taken the place of_sidebar.html.erb.What I've done since and would be the proper approach is to re-run
rails g administrate:views:layoutand merge ones customizations with the latest Administrate layouts.Personally, I'd just close this issue.