Skip to content

Commit

Permalink
Updated documentation for parent method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Smith committed Nov 13, 2013
1 parent 02302be commit c396bcc
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,22 @@ class Person
end
```

Your association has access to it's ```parent``` object as well.

```ruby
class Person
include Soulless.model

attribute :name, String

validates :name, presence: true

has_one :children do
attribute :name, String, default: lambda { "#{parent.name} Jr." }
end
end
```

When you need to make sure an association is valid before processing the object use ```validates_associated```.

```ruby
Expand All @@ -196,6 +212,8 @@ class Person
validates :name, presence: true
end

validates_associated :spouse

...

end
Expand Down

0 comments on commit c396bcc

Please sign in to comment.