Hi,

The second version doesn't allow to pass arguments to the validation type.

You can use this syntax :

    with_options presence: true do |opts|
      opts.validates :name
      opts.validates :email, uniqueness: true
    end

Best regards.

-----
Geoffrey Roguelon

Le 11 avr. 2013 à 15:59, Roman <[email protected]> a écrit :

> Hi,
> What do you think about the following way to specify validations?
> 
>     validates name: {presence: true}, email: {uniqueness: true, presence: 
> true}
> 
> or even
> 
>     validates name: [:presence], email: [:uniqueness, :presence]
> 
> Right now this requires 2 calls to `validates`
> 
>     validates :user, presence: true
>     validates :email, uniqueness: true, presence: true
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to