I've a variable registered(boolean) in my table User. Because when a connected user want to use an Email, if this email is not existing into the table User, a new line is created in the Users (only with the variable email, and registered = false). So I would like that when a user registers, he will not be blocked if(email exist && registered == false). In this case, the password will be replaced, and the variable registered change to true.
I would like to run something like that :
def create
@user_registred = User.find(email: params[user: :email])
if @user_registred.any?
if @user_registred.registred == false
@user = User.update(params[:user])
else
notice: "Email already taked"
end
else
@user = User.new(params[:user])
end
end