Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def create
- @account = Account.new(params[:account])
- @account.new_password = true
- @user = AccountHolder.new(params[:user])
- @blog = Blog.new(params[:blog])
- all_valid = true
- all_valid = false unless @blog.valid?
- all_valid = false unless @user.valid?
- if all_valid
- begin
- Account.transaction(@account, @blog, @user) do
- @plan = Plan.find_by_name('free')
- @administrator = Role.find_by_name('administrators')
- if @account.save and @blog.save and @user.save
- key = @user.generate_security_token
- url = url_for(:action => 'validate', :user_id => @user.id, :key => key)
- # AccountMailer.deliver_signup_confirmation(@user, @account, @blog, url)
- flash[:notice] = 'Signup successful!'
- flash[:notice] << ' Please check your registered email account to verify your account registration and continue with the login.'
- end
- @account.subscriptions.create(:plan => @plan)
- @account.web_applications << @blog
- @blog.users << @user
- @user.account = @account
- @user.assignments.create(:role => @administrator)
- end
- rescue Exception => e
- flash.now[:notice] = nil
- flash.now[:warning] = 'Error creating account: confirmation email not sent'
- logger.error "Unable to send confirmation E-Mail:"
- logger.error e
- render :action => :new and return
- end
- redirect_to :controller => "user" and return
- end
- render :action => "new"
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement