Sunday, February 19, 2006

HABTM and attributes: Adding to self referential relations

One way you can add to a self referential relationship:
self.links << wp unless self.links.include?(wp)

and another way to add with attributes:

self.links.push_with_attributes(wp, { "link_text" => url[1] } ) unless self.links.include?(wp)

0 Comments:

Post a Comment

<< Home

eXTReMe Tracker