Tableless validation in Rails 4.2 -


i trying validate form, not bound real model, did following:

a model

class formrequest      include activemodel::model      attr_accessor :email      validates :email, presence: true, email: true  end 

and method in controller

# form shown def index     @form_request = formrequest.new end 

but when load page error:

unknown validator: 'emailvalidator'

what did miss?

you don't have email: true validator.

to validate email can use regular expression:

valid_email = /\a[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates :email, presence: true, format: { with: valid_email } 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -