i'm trying to validate the presence on a parameter in rails. this is the code snippet for User.rb
validates :terms_of_service, presence: true
validates :privacy_policy, presence: true
Ideally , i would like rails to throw an error if this parameter is not present
here is a sample parameter list sent by the client
Parameters: {"username"=>"f", "email"=>"f@f.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "confirm_success_url"=>"http://localhost:4000", "config_name"=>"default", "registration"=>{"username"=>"f", "email"=>"f@f.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "confirm_success_url"=>"http://localhost:4000"}}
However, rails throws the below error
NoMethodError (undefined method `terms_of_service' for #<User:0x007f16d402e788>):
why does it think that there should be a terms_of_service
method when i'm actually testing a parameter?
Aucun commentaire:
Enregistrer un commentaire