Skip to content
Extraits de code Groupes Projets
Valider 01d26f6d rédigé par Raphael's avatar Raphael
Parcourir les fichiers

Using custom registrations controller

parent e0ffc8bb
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -8,8 +8,21 @@ class RegistrationsController < Devise::RegistrationsController ...@@ -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 ...@@ -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 @@ ...@@ -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 ...@@ -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
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter