Where to put Global variables in Rails 3

后端 未结 5 1772
旧时难觅i
旧时难觅i 2020-11-30 03:25

I used to put Global variables in environment.rb with my Rails 2.3.8 application such as:

MAX_ALLOWD_ITEMS = 6

It doesn\'t seem to work in

5条回答
  •  暖寄归人
    2020-11-30 03:59

    I usually go with application_helper.rb This is what it looks like:

    module ApplicationHelper
      def my_global_variable 
        my_global_variable = "Helloworld!"      
      end
    end
    

    Then I can put in my_global_variable anywhere as a function.

提交回复
热议问题