I am confused in defining constant in Rails 1.2.3.
Here I want to define one of the url in constant and want to access at any controller. For example ::
TEMPLATE_URL = "www.google.com"
Now I want to access in any of the controller. Then I am unable to define and access thi开发者_C百科s constant.
Add following in application_controller.rb (OR application.rb)
TEMPLATE_URL = "www.google.com"
and you can access it any controller using
puts TEMPLATE_URL # www.google.com
If you want to use the same variable in your any views/helpers/models you can use it following way
ApplicationController::TEMPLATE_URL
精彩评论