Hi,
I have a model (let’s say User) and I would like to add any number of
user-defined-settings to this Model. I created a UserSetting Model
with user_id, key and value. I connected them with has_many. I know
how to access these properties from a user but I would like some
methods like user.hasProperty? / user.getProperty …
I think I know how to write these methods/finders myself but it seems
like a pretty common problem to me, which means there could be an
easier way of doing the same. Is there?
bye
Frank
On Jan 26, 2006, at 5:44 AM, Frank S. wrote:
easier way of doing the same. Is there?
Nothing automatic, but the code seems trivial anyway:
def get_property(property)
user_settings.find_by_key(property)
end
alias has_property? get_property
Duane J.
(canadaduane)
http://blog.inquirylabs.com/
On 1/26/06, Duane J. [email protected] wrote:
alias has_property? get_property
I think you misunderstood me. If I’m not mistaken, you code would
return the same property for every user… But these property will be
different for every user.
bye
Frank
http://amazing-development.com