validates_present :author

On Tue, Jun 30, 2009 at 6:34 PM, robs<[email protected]> wrote:
>
> For example:
>
> class Person
>  include DataMapper::Resource
>
>  property :id,           Integer, :serial => true
>  property :first_name,   String, :nullable => false
>  property :last_name,    String
>
>  has n :posts
> end
>
> class Post
>  include DataMapper::Resource
>
>  property :id,           Integer, :serial => true
>  property :title,   String, :nullable => false
>  property :body,  Text
>
>  belongs_to :author, :class_name => "Person"
> end
>
> What would be the best way to validate the presence of an author when
> a post is saved? I noticed that the documentation says that some
> validations are automatically inferred (e.g., if :nullable => false
> or :length is specified). Is there any way to include this validation
> in the belongs_to method call? If not, what would anyone suggest?
>
> Thanks!
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" 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/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to