RS, DG; You can now sign up to be a user on a seed
This commit is contained in:
parent
8b9cd3453d
commit
0fb55be7a0
3 changed files with 20 additions and 6 deletions
|
|
@ -27,9 +27,9 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
@user = User.new(params[:user])
|
||||
|
||||
if @user.person.save! && @user.save!
|
||||
@user = User.instantiate(params[:user])
|
||||
|
||||
if @user.created_at && @user.person.created_at
|
||||
flash[:notice] = "Successfully signed up."
|
||||
redirect_to root_path
|
||||
else
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ class User
|
|||
###Helpers############
|
||||
def self.instantiate( opts = {} )
|
||||
opts[:person][:email] = opts[:email]
|
||||
opts[:person][:serialized_key] = generate_key
|
||||
User.create( opts)
|
||||
end
|
||||
|
||||
|
|
@ -148,4 +149,8 @@ class User
|
|||
OpenSSL::PKey::RSA::generate 1024
|
||||
end
|
||||
|
||||
def self.generate_key
|
||||
OpenSSL::PKey::RSA::generate 1024
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,15 +3,24 @@
|
|||
= devise_error_messages!
|
||||
%p
|
||||
= f.label :email
|
||||
%br/
|
||||
= f.text_field :email
|
||||
%p
|
||||
= f.label :password
|
||||
%br/
|
||||
= f.password_field :password
|
||||
%p
|
||||
= f.label :password_confirmation
|
||||
%br/
|
||||
= f.password_field :password_confirmation
|
||||
|
||||
= f.fields_for :person do |p|
|
||||
= p.hidden_field :url, :value => "http://google.com/"
|
||||
|
||||
= p.fields_for :profile do |pr|
|
||||
%p
|
||||
= pr.label :first_name
|
||||
= pr.text_field :first_name
|
||||
%p
|
||||
= pr.label :last_name
|
||||
= pr.text_field :last_name
|
||||
|
||||
%p= f.submit "Sign up"
|
||||
= render :partial => "devise/shared/links"
|
||||
|
|
|
|||
Loading…
Reference in a new issue