I am new to Rails. I am trying to create user management + login system using Devise. All is great except two things:
1) Is there any way to remove "email" field and/or validation when signing up? When remove :validatable from model, then passwords doesn't validate 开发者_StackOverflowtoo.
2) What is best way to make user management in system? Something like overriding devise sign up?
I was searching in google for answers and readed documentation, but don't found answers.
Thank you.
1) You should remove :validatable and write your own validation in User model.
2) You can create users by hand in devise:
@user = User.new(:field1 => "something", :field2 => "something else", :password => "secret", :password_confirmation => "secret")
@user.save
if created object passes validation it will be created just like with devise signup action.
You can remove email validation with
def email_required?
false
end
in your User model
1) I don't know from which version onwards, but at least at that time when you where asking your question, there was already a tutorial at the devise github page how to do it. They outline two ways, one was described here, how to manage that. And you can keep their validations.
2) As for CRUD users they also have a tutorial which is a bit more recent.
Hope this still helps someone ;-)
精彩评论