On Apr 4, 8:15 pm, Conrad Taylor <[email protected]> wrote:
> On Sun, Apr 4, 2010 at 11:46 AM, Chris Habgood <[email protected]> wrote:
> > Is there not a way to form a string convert it to an attribute and then do
> > Model.(string converted to attribute)?
>
> Chris, you can do the following:
>
> class Dynamic
>
>   name = foo
>   ivar = "@#{name}"  # form the string
>
>   define_method( "#{name}=" ) do |value|
>      instance_variable_set( ivar, value )   # create an attribute
>   end
>

Not with Active Record attributes - they're not instance variables.

Fred

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to