A website template with lots of features, built with ruby on rails.

user.rb 1.0KB

1234567891011121314151617181920212223242526272829303132333435
  1. class User < ActiveRecord::Base
  2. # Include default devise modules. Others available are:
  3. # :confirmable, :lockable, :timeoutable and :omniauthable
  4. devise :database_authenticatable, :async, :registerable,
  5. :recoverable, :rememberable, :trackable, :validatable
  6. validates :password, presence: true, length: {minimum: 5, maximum: 120}, on: :create
  7. validates :password, length: {minimum: 5, maximum: 120}, on: :update, allow_blank: true
  8. has_many :posts
  9. mount_uploader :avatar, AvatarUploader
  10. process_in_background :avatar
  11. def full_name
  12. name = self.first_name.to_s + ' ' + self.last_name.to_s
  13. return name
  14. end
  15. after_create do
  16. after_signup_tasks
  17. end
  18. def after_signup_tasks
  19. # Send signup email (worker)
  20. Resque.enqueue(SendSignupMessage, self.id)
  21. # Add user to subscription list
  22. if Subscription.find_by_email(self.email) == nil
  23. Subscription.create(first_name: self.first_name, last_name: self.last_name, email: self.email)
  24. end
  25. # Mixpanel Tracking Analytics
  26. end
  27. end