Using custom registrations controller
This commit is contained in:
parent
e0ffc8bba0
commit
01d26f6d0e
4 changed files with 16 additions and 5 deletions
|
|
@ -8,8 +8,21 @@ class RegistrationsController < Devise::RegistrationsController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
User.instantiate!(params[:user])
|
begin
|
||||||
redirect_to root_url
|
user = User.instantiate(params[:user])
|
||||||
|
rescue MongoMapper::DocumentNotValid => e
|
||||||
|
user = nil
|
||||||
|
flash[:error] = e.message
|
||||||
|
end
|
||||||
|
puts user
|
||||||
|
if user
|
||||||
|
#set_flash_message :notice, :signed_up
|
||||||
|
flash[:notice] = "You've joined Diaspora!"
|
||||||
|
#redirect_to root_url
|
||||||
|
sign_in_and_redirect(:user, user)
|
||||||
|
else
|
||||||
|
redirect_to "/get_to_the_choppa"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|
|
||||||
|
|
@ -289,7 +289,7 @@ class User
|
||||||
def self.instantiate( opts = {} )
|
def self.instantiate( opts = {} )
|
||||||
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{opts[:url]}"
|
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{opts[:url]}"
|
||||||
opts[:person][:serialized_key] = generate_key
|
opts[:person][:serialized_key] = generate_key
|
||||||
User.create(opts)
|
User.create!(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
def seed_aspects
|
def seed_aspects
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
|
|
||||||
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
|
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
|
||||||
= devise_error_messages!
|
|
||||||
= f.hidden_field :url, :value => request.host
|
= f.hidden_field :url, :value => request.host
|
||||||
%p
|
%p
|
||||||
= f.label :username
|
= f.label :username
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,6 @@ describe Aspect do
|
||||||
it 'belong to a user' do
|
it 'belong to a user' do
|
||||||
@aspect.user.id.should == @user.id
|
@aspect.user.id.should == @user.id
|
||||||
@user.aspects.size.should == 3
|
@user.aspects.size.should == 3
|
||||||
@user.aspects.first.id.should == @aspect.id
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should have people' do
|
it 'should have people' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue