Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scoped routes broken in global navigation #960

Closed
djonasson opened this issue Feb 1, 2012 · 3 comments
Closed

Scoped routes broken in global navigation #960

djonasson opened this issue Feb 1, 2012 · 3 comments
Milestone

Comments

@djonasson
Copy link

All my routes are scoped by language like this:

MyApp::Application.routes.draw do
  scope '(:language)' do
    ActiveAdmin.routes(self)
  end
end

In my ApplicationsController.rb I have implemented the url_options method like this:

def url_options
  { :language => current_language }.merge(super)
end

The current language shows up fine in the action links (default_actions) but in the main menu the language is ignored causing my site to change language when navigating the menu.

Anyone else experiencing similar problems?

@pranik
Copy link

pranik commented Feb 2, 2012

Seems that MenuItem.generate_url(named_scope) that use Rails.application.routes.url_helpers.send(named_route) doesn't consider url_options or route scopes.
I excluded it from render menu_item.

In method build_menu_item in tabbed_navigation.rb I changed

link_to item.name, item.url

in

link_to item.name, send(item.url)

and in menu_item.rb I changed method url in

def url
  @url
end

I think the best solution would be to call the 'send' in a MenuItem, but I do not know how to include the "url helpers" like this:

module ActiveAdmin
  class MenuItem
    include Module::With::Access::To::ActiveAdmin::UrlHelper

    def self.generate_url(named_route)
      send(named_route)
    end

gregbell added a commit that referenced this issue Feb 3, 2012
Doing this ensures that the full Rails router has been loaded including
any scoping and RackBaseURI configurations.

Fixes #101, #960
@gregbell
Copy link
Contributor

gregbell commented Feb 3, 2012

Should be fixed on master by 3e7ac40

@gregbell gregbell closed this as completed Feb 3, 2012
@djonasson
Copy link
Author

Sounds great, thanks! I'll check it out as soon as I get back to the office.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants