default_url_options and rails 3

后端 未结 5 635
难免孤独
难免孤独 2020-11-29 05:50

As ActionController::Base#default_url_options is deprecated, I wonder how to set default url options in rails3. The default url options are not static but dependent of the c

5条回答
  •  天涯浪人
    2020-11-29 06:30

    I believe the preferred method is to now tell the router to handle this:

    Rails.application.routes.default_url_options[:foo]= 'bar' 
    

    You can put this line in either routes.rb or an initializer. Whichever you would prefer. You could even put it in your environment configs if the values change based on your environment.

提交回复
热议问题