Ruby on Rails Thursday, May 24, 2012

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 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.

No comments:

Post a Comment