List Info

Thread: common global resources




common global resources
user name
2006-09-07 12:23:07
hello!

I'm looking for the best option to declare global variables
and 
constants in my web application, that can be accessed from
anywhere of 
my program.

I decided to declare the global constants in the
ApplicationController, 
like this:

class ApplicationController < ActionController::Base
    PROJECT_TYPE = 1
end

and accessing this constant in the next way (index.rhtml):

<%= ApplicationControll::PROJECT_TYPE %>

but I guess is not the best option to do this.

There is another way???

thank you very much (and sorry for my english).

-- 
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-talkgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---

common global resources
user name
2006-09-07 15:03:20
Gonzalo,

You can create a hash in environnment.rb:

CONFIG = {
  :page_size => 30,
}

and then use it anywhere in your app: CONFIG[:page_size]

Jean-Etienne

-- 
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-talkgooglegroups.com
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribegooglegroups.com
For more options, visit this group at http:
//groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )