问题
I need you help
Try: model/user.rb
link to source
but it does not work
回答1:
Simply comment out the line specifying validators for the email attribute, or remove it altogether:
# app/models/user.rb
# validates :email, :presence => false, :email => false
You'll also need to make a slight modification to your users
table. By default, Devise does not allow the email
field to be null. Create and run change a migration that allows email
to be null
.
# in console
rails g migration AddChangeColumnNullToUserEmail
# migration file
class AddChangeColumnNullToUserEmail < ActiveRecord::Migration
def self.up
change_column :users, :email, :string, :null => true
end
def self.down
change_column :users, :email, :string, :null => false
end
end
回答2:
This is the link to the validate.rb file of devise. You can see a method email_required? in the model. So I guess
def email_required?
false
end
in your User model should remove the necessity while registering.
回答3:
From this question, I guess, your email field is not required field.
IF this,
Try just remove the code: :validatable
from your user.rb mudel.
来源:https://stackoverflow.com/questions/17021367/how-to-disable-email-validation-in-rails-device