quyetdc
quyetdc

Reputation: 1585

Rails - How to organize constants

I am having some constants that I want to define globally in my applications. Also, these constants don't belong to any model. What's the best practice to organize those constants.

Any advice is highly appreciated

Upvotes: 3

Views: 311

Answers (1)

M.Elkady
M.Elkady

Reputation: 1133

simple you can define Module called as example Constants and define it inside the module

module Constants
  CONST1="value"
  CONST2="value2"
end

it's possible also to group them like

 module Constants
  module Group1
    CONST1="value"
    CONST2="value2"
  end
  module Group2
   # some relevant constants 
  end 
end

Upvotes: 1

Related Questions