judge
1
Hi,
I have an ActiveRecord model Group and a YAML table stored in
config/users.yaml just like:
- {login: titi, password: 123456, group_id: 2}
- {login: toto, password: 987654, group_id: 7}
And I would like to link them by a sexy way. Can you help me?
I would be happy if I can do this (as example): User.first.group.id # =>
2
Many thanks for any help!
judge
2
Paul A. wrote:
Hi,
I have an ActiveRecord model Group and a YAML table stored in
config/users.yaml just like:
- {login: titi, password: 123456, group_id: 2}
- {login: toto, password: 987654, group_id: 7}
And I would like to link them by a sexy way. Can you help me?
I would be happy if I can do this (as example): User.first.group.id # =>
2
Many thanks for any help!
This will probably be easier in Rails 3, but not impossible in Rails 2.
Which are you using?
Best,
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
judge
3
Marnen Laibow-Koser wrote:
This will probably be easier in Rails 3, but not impossible in Rails 2.
Which are you using?
Thank for your quick answer. I’m using Rails 3 
judge
4
judge
5
On 31 May 2010 22:43, Paul A. [email protected] wrote:
I would be happy if I can do this (as example): User.first.group.id # =>
2
You could run a rake task to put the data in the database, unless
there is a good reason why you need it in a yaml file.
Colin
judge
6
Colin L. wrote:
On 31 May 2010 22:43, Paul A. [email protected] wrote:
I would be happy if I can do this (as example): User.first.group.id # =>
2
You could run a rake task to put the data in the database, unless
there is a good reason why you need it in a yaml file.
I have 3 goods reasons for that:
- data access is faster
- read-only is sufficient
- it’s DRY (I don’t repeat data between rake task and database: the
YAML file is my data)
I think Active Hash is awesome. Really awesome.