-1

I have given server side validation of nested form. each of that having model and in that given server side validation. But, main of that form of in model server side validation working of at the time of save, which i have disabled it. but, also i have disabled nested forms model server side validation, but it is not working.

 validates_presence_of :user_mob, :message => 'please enter the mobile number.' ,unless: :skip_valid validates_presence_of :address, :message => 'please enter the address.', unless: :skip_valid 

//this is main model

class UserDetails< ActiveRecord::Base belongs_to :u_user_details, :foreign_key => 'u_id'

validates_presence_of :year, :message => 'please enter the details.', unless: :skip_valid validates_presence_of :user_name, :message => 'please enter the details.', unless: :skip_valid validates_presence_of :user_address, :message => 'please enter the details.', unless: :skip_valid validates_presence_of :user_mobile, :message => 'please enter the details.', unless: :skip_valid validates_presence_of :user_type, :message => 'please enter the details.', unless: :skip_valid 

end

Even I am giving unless: skip_valid in netsted forms model. it is not working. how to disable nested forms model server side validation.

2
  • The easiest way to skip validation is to call save(false) the false indicates that you do not want to run validationsCommentedApr 18, 2019 at 13:14
  • Also I am giving skip validation false at the time of save, till not yet workingCommentedApr 19, 2019 at 8:35

1 Answer 1

0

validates_presence_of :year, :message => 'please enter the details.', if: ->(u) { u.commit == 'submit' or u.commit == 'approve' or u.commit == 'reapply'}

We can do it like this.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.