Ruby on Rails
Friday, May 25, 2012
Well this is what it says in config/application.rb
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
And this is what I've done... created a file in the initializers directory.
On Thursday, May 24, 2012 11:05:20 AM UTC-4, Ruby-Forum.com User wrote:
Hi All,--
I'm building an app that compares statistics from sports games. Each
statistic has an "action" that defines what happened at that point in
time, for example "player has possession" is one such action string.
I use these strings to pull out / sort the statistics into meaningful
information, so these strings are used throughout the app.
I want to know a good place to have a list of global variables like
this. I have tried :
creating file called action_string_constants.rb in /lib.
In this file I declare a module :
module ActionStringConstants
MB_ACTION_STRING_PLAYER_HAS_POSSESSION = "player has posession"
end
I then try and use this in another class such as Player (model) with
include ActionStringConstants
However this returns a NameError (uninitialized constant
Player::ActionStringConstants):
I then thought of including this in application.rb, as I want to use
these constants in many files, but this returns a similar error when
trying to launch the app.
Where can I declare a string constant??!
This really should be simple!
--
Posted via http://www.ruby-forum.com/.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/iTmmCaUxJxsJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment