Controller parameter in item brokes nested resources
radeno opened this issue · comments
Hi,
for first, Navigasmatic is really great! :)
For second, when i use controller parameter in navigation item brokes router for nested resources.
One example for thousands words:
= semantic_navigation :user, config: :bootstrap, class: 'pull-right' do |n|
- n.item 'title', controller: 'categories'
- n.item 'user profile', edit_user_registration_path
It generates link path correctly but when is clicked on user profile it gives:
No route matches {:controller=>"devise/categories"}
Right route is devise/registrations
When is used categories_path
it works.
So typically with an item that links you need to provide a controller and an action -- to route properly it needs to know the action.
You could try:
- n.item 'title', controller: '/categories' # will remove the devise part by placing it at root
- n.item 'title', controller: '/categories', action: 'index' # will always put them at index
- n.item 'title', controller: '/categories', action: 'index', highlights_on: {controller: 'categories'} # this should always highlight on the categories controller (shouldn't matter where it is)
Same error on every solution.
Initial slash doesn't help. :/
You have this in the initializer and you've restarted your server?
I don't have it in intializer. It is directly in the view.
Maybe I'm confused about what you want to accomplish.. Navigasmic just calls url_for
behind the scenes if you pass it a hash for the link (eg. controller/action/etc).
It even handles namespacing routes within an engine by allowing you to do things like:
- n.item 'title', engine_name.url_for(controller: 'foo')
Play around with url_for, since that's all it's using in your example.. I just don't know if you want it to be nested within devise, or if you don't want it to be nested.. I would assume not, and the solution I specified should fix it as it does for me.
It is weird. I try this:
url_for(controller: '/categories')
and it works
but controller: '/categories'
doesn't
Ok, get it, it must by double slashed
controller: '//categories', highlights_on: {controller: 'categories'}
but highlights_on doesnt work instead
it returns highlighting rules should be an array containing any of/or a Boolean, String, Regexp, Hash or Proc
Weird.. I don't understand why it needs to be double slashed unless you've done something odd with routing.. is the route for the categories controller nested within a namespace for devise? As for the highlighting, it works perfectly in my examples:
Can you provide clarification? otherwise I have to assume that's not the case -- since it works in the example.
No no,
it is simple routing:
resources :categories
devise_for :users
namespace :taxonomy do
resources :taxonomies
end
View navigations:
= semantic_navigation :user, config: :bootstrap, class: 'pull-right' do |n|
- n.item Category.model_name.human(count: 2), controller: '/categories'
- n.item 'Profile', edit_user_registration_path
Errors:
No route matches {:controller=>"devise/categories"}
No route matches {:controller=>"taxonomy/categories"}
Any resolution on this?