Guest User

Untitled

a guest
Aug 29th, 2018
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. Weird delayed_job behaviour
  2. class User < ActiveRecord::Base
  3. devise :database_authenticatable, :registerable,
  4. :recoverable, :rememberable, :trackable, :validatable
  5. attr_accessible :email, :password, :password_confirmation, :remember_me, :country, :phone_number, :opt_in
  6.  
  7. def email=(email)
  8. super
  9. Delayed::Job.enqueue self
  10. end
  11.  
  12. def perform
  13. begin
  14. UserMailer.welcome_email self
  15. rescue => e
  16. STDERR.puts "Cannot perform the mailer: #{e}"
  17. end
  18. end
  19. end
  20.  
  21. def create
  22. user = User.new({:email => params[:email],
  23. :password => params[:password],
  24. :password_confirmation => params[:password_confirmation],
  25. :country => params[:country],
  26. :opt_in => Boolean(params[:opt_in]),
  27. :phone_number => params[:phone_number]})
  28.  
  29. if user.save(:validate => false)
  30. redirect_to wrap_users_path
  31. end
  32. end
Add Comment
Please, Sign In to add comment