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! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-May-31 21:58 UTC
Re: ActiveRecord model relationship with YAML file
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 marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 :p -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hmm, http://github.com/zilkey/active_hash looks very cool. And Rails 3 ready. But it do not allow habtm relations :s -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 31 May 2010 22:43, Paul A. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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 # => > 2You 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> > Many thanks for any help! > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Colin Law wrote:> On 31 May 2010 22:43, Paul A. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.