you could just write a getter/setter for each custom attr to point
back to the reflected attr:
class MyClass < ActiveRecord::Base
def my_foo
self[:foo]
end
def my_foo=(val)
self[:foo] = val
end
end
On Oct 13, 5:14 pm, Greg Willits
<li...-0Bv1hcaDFPRk211Z5VL+QA@public.gmane.org>
wrote:> OK, so I get ActiveRecord determines model attributes through
> reflection of the table schema. Handy for many cases, but not mine.
>
> I need to override that and provide my own mapping of attribute names
> (for use in all app-specific code) to column names.
>
> I''ve been poking around looking for how that might be done like I
see
> table_name and other attributes can be, but so far I''m coming up
empty.
>
> I''ve written/been using my own framework for years in another
> language that handled all this (more of a table gateway than an
> ActiveRecord pattern), so I can do it, just wondering if Rails has
> it, and if not, what''s the best, i.e. Ruby/Rails "right
way" to add
> it (extend AR modules? write a super class for all my models? write a
> utility class for all my models to use, other?)
>
> (For those of you that want to know why, I can elaborate, but I''ll
> spare us the bulk until needed.)
>
> -- gw
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---