Reputation: 2673
I'm using devise authentication gem in Rails with mongoid, all the latest versions(Rails 4.2,mongoid 5,devise 3.5,ruby 2.2.3).
I have added :database_authenticatable module to my model(which is Researcher) and have done all the instructions in this page to sign in with username, I also have validatable and confirmable.
My problem is that devise validates username as email so when I put for example user it says "you forgot to add the @ sign to the email", Here is a screenshot:
this is my rake routes
:
Prefix Verb URI Pattern Controller#Action
root GET / researchers#new
new_researcher_session GET /researchers/sign_in(.:format) researchers/sessions#new
researcher_session POST /researchers/sign_in(.:format) researchers/sessions#create
destroy_researcher_session DELETE /researchers/sign_out(.:format) researchers/sessions#destroy
cancel_researcher_registration GET /researchers/cancel(.:format) researchers#cancel
researcher_registration POST /researchers(.:format) researchers#create
new_researcher_registration GET /researchers/sign_up(.:format) researchers#new
edit_researcher_registration GET /researchers/edit(.:format) researchers#edit
PATCH /researchers(.:format) researchers#update
PUT /researchers(.:format) researchers#update
DELETE /researchers(.:format) researchers#destroy
researcher_confirmation POST /researchers/confirmation(.:format) researchers/confirmations#create
new_researcher_confirmation GET /researchers/confirmation/new(.:format) researchers/confirmations#new
GET /researchers/confirmation(.:format) researchers/confirmations#show
researchers GET /researchers(.:format) researchers#index
POST /researchers(.:format) researchers#create
new_researcher GET /researchers/new(.:format) researchers#new
edit_researcher GET /researchers/:id/edit(.:format) researchers#edit
researcher GET /researchers/:id(.:format) researchers#show
PATCH /researchers/:id(.:format) researchers#update
PUT /researchers/:id(.:format) researchers#update
DELETE /researchers/:id(.:format) researchers#destroy
the screenshot is /researchers/sign_up page.
and this is my project hierarchy, controllers:
tree app/controllers
app/controllers
├── application_controller.rb
├── concerns
├── researchers
│ ├── confirmations_controller.rb
│ └── sessions_controller.rb
└── researchers_controller.rb
views:
app/views
├── application
├── layouts
│ ├── application.html.erb
│ ├── mailer.html.erb
│ └── mailer.text.erb
├── researchers
│ ├── confirmations
│ │ └── new.html.erb
│ ├── new.html.erb
│ ├── sessions
│ │ └── new.html.erb
│ └── show.html.erb
└── researchers_confirmation
├── confirmation_instructions.html.erb
└── confirmation_instructions.text.erb
I'm ready to add any information necessary.
I only have devise right now, this problem occurred even when I didn't have confirmable and validatable .
As for the message in the screenshot, I have ar.yml for arabic locale, I set default locale to english for the purpose of the screenshot but seems devise didn't listen to me, the message in the screenshot is the translation of the english text "Please add the "@" sign to the email address because "user" lacks the "@" sign".
By the way I know there is reg_exp for email in devise initializer but I'm afraid If changed that , devise won't validate email field as email.
Upvotes: 1
Views: 90
Reputation: 5197
Maybe the problem is in the view of the form. I think that the warning message is fired by the browser and not by your js validation.
Check if you wrongly set input type=email
also for username field.
Upvotes: 1