![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, I was wondering if there is a right way to keep some static arrays of data inside the application. |
#3
| |||
| |||
|
|
Hi, On Thu, 2009-11-05 at 17:55 -0800, Zovar wrote: Hello, I was wondering if there is a right way to keep some static arrays of data inside the application. I'd consider storing them in the models to which they relate. If they need their own models, that's easy too. The models don't have to inherit from ActiveRecord. |

|
HTH, Bill |
#4
| |||
| |||
|
|
bill walton wrote: Hi, On Thu, 2009-11-05 at 17:55 -0800, Zovar wrote: Hello, I was wondering if there is a right way to keep some static arrays of data inside the application. I'd consider storing them in the models to which they relate. If they need their own models, that's easy too. The models don't have to inherit from ActiveRecord. I'm about to try something kind of similar. I'm going to be experimenting with storing state and country info outside the DB, since it's static and relatively small. I hope to use one of the tableless AR libraries to make the data act like an AR model, though. Perhaps I'll find out why no one does this... ![]() ---- |
#5
| |||
| |||
|
|
Hi, On Thu, 2009-11-05 at 17:55 -0800, Zovar wrote: Hello, I was wondering if there is a right way to keep some static arrays of data inside the application. I'd consider storing them in the models to which they relate. *If they need their own models, that's easy too. *The models don't have to inherit from ActiveRecord. HTH, Bill --~--~---------~--~----~------------~-------~--~----~ |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
Hello, I was wondering if there is a right way to keep some static arrays of data inside the application. I want to be able to access them globally. (it's not for setting vars, just simple arrays, i.e. ['ICQ', 'AIM', 'GTALK'] etc). Also I don't wan't to use a database for that, need a hardcoded option. Read o the forum, that some people use environment.rb, but wasn't sure about that. I would like to have a separate file for each array of data, but what is the best practise for that? Just create rb files in a separate folder? |
#8
| |||
| |||
|
#9
| |||
| |||
|
|
On Nov 5, 8:55�pm, Zovar <peter.zavor... (AT) gmail (DOT) com> wrote: data, but what is the best practise for that? Just create rb files in a separate folder? Some good solutions here already, but one that I didn't see mentioned was YAML. [...] |
#10
| |||
| |||
|
|
class SomeModel < AR::Base FOO_LOOKUP = YAML::load_file(File.join(RAILS_ROOT, 'config', 'foo_lookup.yml')) end |
![]() |
| Thread Tools | |
| Display Modes | |
| |