Answer the question
In order to leave comments, you need to log in
In Rails, if the model has validates :password, presence: true, then how can you remove this obligation elsewhere?
The matter is that I want to implement functions for users (user), that is, adding and editing. And here in the model class is present:
class User < ActiveRecord::Base
validates :password, presence: true
end
Answer the question
In order to leave comments, you need to log in
There are at least 2 ways
1. validates_presence_of :password, :on => :create
2. object.save(:validate => false)
have you tried them? why don't they suit you?
Turn off validation when saving.
Or define its use only when creating an object, above anyd3v answered correctly.
to help
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question