On Wed, May 11, 2011 at 2:36 AM, Quee WM <li...@ruby-forum.com> wrote:

> Hi,
>
> I am trying to use the new rails 3 validations and running into some
> issues.
>
> for my password I have,
>
> validates :password,    :presence => {:on => :create},  :length => {
> :minimum => 5, :maximum => 16 },  :confirmation => true
>
> the presence and length are creating problem.
>
> I only want to be able to check for the password at create time to
> confirm if it is present.
>
> at update time if someone enters the password it should still match the
> size limit but it they do not enter the password then it should not be
> looked at.
>

My sense is that what is tripping things up is that on update and nil
password, it is not checking precence but is still checking length and
confirmation. It may not be the best way but I tend to use an :if =>
:method_name, and then in that method check for new_record, etc.


>
> in my controller i have already added:
>
> params[:user].delete(:password) if params[:user][:password].blank?
> params[:user].delete(:password_confirmation) if
> params[:user][:password].blank? and
> params[:user][:password_confirmation].blank?
>
> to take care of any issue coming from that side.
>
> any help or suggestion will be greatly appriciated.
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> 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.
>
>

-- 
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