Sunday, January 30, 2011

[Rails] Re: Access parent object instance variable

On Jan 31, 12:29 am, "Ellicks M." <li...@ruby-forum.com> wrote:
>
> So, essentially on creation of a RollingEvent I'd be passing in a
> reference to the parent Event?

That is how things work in ruby

> Would I have to make a method for every single data member like so:
>
>   def amount
>     @parent_event.amount
>   end
>   def title
>     @parent_event.title
>   end
> end

You could just write @parent_event.amount each time, although there's
no harm in writing the above (You might also want to read up on
delegation)

Fred
>
> ??
>
> --
> Posted viahttp://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@googlegroups.com.
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate