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
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@user = User.new(params[:user])
|
@user = User.instantiate(params[:user])
|
||||||
|
|
||||||
if @user.person.save! && @user.save!
|
if @user.created_at && @user.person.created_at
|
||||||
flash[:notice] = "Successfully signed up."
|
flash[:notice] = "Successfully signed up."
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,7 @@ class User
|
||||||
###Helpers############
|
###Helpers############
|
||||||
def self.instantiate( opts = {} )
|
def self.instantiate( opts = {} )
|
||||||
opts[:person][:email] = opts[:email]
|
opts[:person][:email] = opts[:email]
|
||||||
|
opts[:person][:serialized_key] = generate_key
|
||||||
User.create( opts)
|
User.create( opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -148,4 +149,8 @@ class User
|
||||||
OpenSSL::PKey::RSA::generate 1024
|
OpenSSL::PKey::RSA::generate 1024
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.generate_key
|
||||||
|
OpenSSL::PKey::RSA::generate 1024
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,24 @@
|
||||||
= devise_error_messages!
|
= devise_error_messages!
|
||||||
%p
|
%p
|
||||||
= f.label :email
|
= f.label :email
|
||||||
%br/
|
|
||||||
= f.text_field :email
|
= f.text_field :email
|
||||||
%p
|
%p
|
||||||
= f.label :password
|
= f.label :password
|
||||||
%br/
|
|
||||||
= f.password_field :password
|
= f.password_field :password
|
||||||
%p
|
%p
|
||||||
= f.label :password_confirmation
|
= f.label :password_confirmation
|
||||||
%br/
|
|
||||||
= f.password_field :password_confirmation
|
= 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"
|
%p= f.submit "Sign up"
|
||||||
= render :partial => "devise/shared/links"
|
= render :partial => "devise/shared/links"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue