Advertisement
Guest User

Untitled

a guest
Jul 30th, 2017
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. def create
  2. @account = Account.new(params[:account])
  3. @account.new_password = true
  4. @user = AccountHolder.new(params[:user])
  5. @blog = Blog.new(params[:blog])
  6.  
  7. all_valid = true
  8. all_valid = false unless @blog.valid?
  9. all_valid = false unless @user.valid?
  10.  
  11. if all_valid
  12. begin
  13. Account.transaction(@account, @blog, @user) do
  14. @plan = Plan.find_by_name('free')
  15. @administrator = Role.find_by_name('administrators')
  16.  
  17. if @account.save and @blog.save and @user.save
  18. key = @user.generate_security_token
  19. url = url_for(:action => 'validate', :user_id => @user.id, :key => key)
  20. # AccountMailer.deliver_signup_confirmation(@user, @account, @blog, url)
  21. flash[:notice] = 'Signup successful!'
  22. flash[:notice] << ' Please check your registered email account to verify your account registration and continue with the login.'
  23. end
  24.  
  25. @account.subscriptions.create(:plan => @plan)
  26. @account.web_applications << @blog
  27.  
  28. @blog.users << @user
  29.  
  30. @user.account = @account
  31. @user.assignments.create(:role => @administrator)
  32.  
  33. end
  34. rescue Exception => e
  35. flash.now[:notice] = nil
  36. flash.now[:warning] = 'Error creating account: confirmation email not sent'
  37. logger.error "Unable to send confirmation E-Mail:"
  38. logger.error e
  39. render :action => :new and return
  40. end
  41. redirect_to :controller => "user" and return
  42. end
  43. render :action => "new"
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement