In my application I have used devise for registration purpose and it is working fine.
I have written another sign up method (I have to kept both the sign up methods) and able to register the user. Here is my code
new.html.haml
%h1 User Registration
= form_tag participant_user_registrations_path do
= label_tag :full_name
= text_field_tag :full_name
= label_tag :address
= text_area_tag :address, "", :rows => 5, :cols => 20
= label_tag :mobile_number
= text_field_tag :mobile_number
= label_tag :email
= text_field_tag :email
= label_tag :slogan
= text_area_tag :slogan, "", :rows => 5, :cols => 20
= label_tag :password
= password_field_tag :password
= label_tag :activation_code
= text_field_tag :activation_code
= submit_tag "Sign Up", class: "btn btn-large btn-primary"
In my system username is auto-generated (we have a fixed format for it like full_name + mobile_no)
My user registration method
def another_registration
@user = User.new(:client_id => 122,
:full_name => params["full_name"],
:mobile_number => params["mobile_number"],
:address => params["address"],
:email => params["email"],
:participant_id => params["mobile_number"],
:status => "active",
:slogan => params["slogan"],
:password => params["password"])
if @user.save
flash[:notice] = "User is saved"
else
flash[:alert] = @user.errors.full_messages.first #if @user.errors.any?
end
redirect_to :action => "new"
end
After successfully sign up I have to login the user account.
I have to use existing devise sign in functionality, so how can I call the devise sign in method and how to pass parameters to it.
Currently I am using username and password for the sign in.
Aucun commentaire:
Enregistrer un commentaire