I want to fake an ActiveRecord model like so... instead of having a Plan
table in my database, I''d like to just have a variable somewhere
(shallow example):
Plans = [{ :id => 1, :price => 9.99,
{ :id => 2, :price => 14.99,
{ :id => 3, :price => 19.99 }]
And then I guess I''d still like to be able to associate this with my
User model... so User.plan[:price] brings up 9.99 or whatever. User
belongs_to :plan, so the User would have a plan_id column?
Any tips? Rails 3.
Thanks!
--
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 Tue, Aug 10, 2010 at 8:51 AM, Joao Silva <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I want to fake an ActiveRecord model like so... instead of having a Plan > table in my database, I''d like to just have a variable somewhere > (shallow example): > > Plans = [{ :id => 1, :price => 9.99, > { :id => 2, :price => 14.99, > { :id => 3, :price => 19.99 }] > > And then I guess I''d still like to be able to associate this with my > User model... so User.plan[:price] brings up 9.99 or whatever. User > belongs_to :plan, so the User would have a plan_id column? > > Any tips? Rails 3. >I hate to ask the obvious question here... but why not just have a regular model with a table behind it? What problem are you solving here? What problems are you introducing? Just want to make sure you''re factoring the tradeoffs here... Cheers, Robby -- Robby Russell Chief Evangelist, Partner PLANET ARGON, LLC Web Design and Development with Ruby on Rails http://planetargon.com/ +1 408 372 7466 +1 815 642 4068 [fax] -- 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.
Joao Silva wrote:> I want to fake an ActiveRecord model like so... instead of having a Plan > table in my database, I''d like to just have a variable somewhere > (shallow example): > > Plans = [{ :id => 1, :price => 9.99, > { :id => 2, :price => 14.99, > { :id => 3, :price => 19.99 }] > > And then I guess I''d still like to be able to associate this with my > User model... so User.plan[:price] brings up 9.99 or whatever. User > belongs_to :plan, so the User would have a plan_id column? > > Any tips? Rails 3.You don''t have to "fake it" anymore in Rails 3. Just implement ActiveModel: http://railscasts.com/episodes/219-active-model -- 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.