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

default_url_option prevalences #13184

Closed
daniel2d2art opened this issue Dec 5, 2013 · 3 comments
Closed

default_url_option prevalences #13184

daniel2d2art opened this issue Dec 5, 2013 · 3 comments

Comments

@daniel2d2art
Copy link

default_url_options provided method should override :defaults option on routes entry
and not vice versa.

@dmathieu
Copy link
Contributor

dmathieu commented Dec 5, 2013

Thank you for your interest in rails.
Could you create a sample app reproducing the use case you're describing?
See http://guides.rubyonrails.org/contributing_to_ruby_on_rails.html#creating-a-bug-report

@daniel2d2art
Copy link
Author

Just this code:

routes.rb

  scope '/myscope(/:alternative_param)', :defaults => {:alternative_param => nil}
    namespace :mynamespace do
      resources :foos
    end
  end

foos_controller.rb

  def default_url_options
    {:alternative_param=>params[:alternative_param]}
  en

I say, default params set on "controller#default_url_options" must override the "routes :default" assigment, but works on the contrary routes override the provide callback functionality to defalut_ulr_option.

@pixeltrix
Copy link
Contributor

I would say that Controller#default_url_options should override default_url_options in routes.rb but not override a route's defaults because it's a global setting whereas a route's defaults are specific. There are plenty of ways you can achieve what you want by overriding the url helper directly either in a helper or directly on the Rails.application.routes.url_helpers module

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

No branches or pull requests

3 participants