Hi,

I am having difficulties accessing parent properties/attributes from
the child. Anyone could shed some lights onto this?

Heres a sample code:

class Parent < ActiveRecord::Base
  :has_many => :childs
  @connector
  def before_save
    @connector = 'some connector object'
    0..9.do |count|
      self.childs << Child.new
      self.childs[count].connector = @connector
    end
  end
end

class Child < ActiveRecord::Base
  :belongs_to => :parent
  @connector
   def before_save
      # code goes here to access @connector
   end
end

The above is just a recreation of what I am looking to do. So
basically I want to be able to access objects like the connector from
the child, or even the parent itself by something like
self.parent.attributes.

Any ideas?

thanks,

nayeem

--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to