Sha256: b8608bd264ba055101b2ab23235ee59cf0a294f5624ea76a33240a619231d3dc

Contents?: true

Size: 748 Bytes

Versions: 61

Compression:

Stored size: 748 Bytes

Contents

module Wheels
  module ActiveRecordUserExtensions
    def create_profile
      self.profile ||= Profile.create(:user => self)
    end

    def role=(role)
      if role.kind_of? Role
        self.role_id = role.id
      else
        role = role.to_s.camelize
        if role.is_numeric?
          self.role_id= role
        else
          self.role_id= Role.find_by_name(role).id
        end
      end
    end

    def confirm!
      self.confirmed_at = DateTime::now
      save
    end
  end
end

User.send :include, Wheels::ActiveRecordExtensions

User.before_create :create_profile
User.belongs_to :role
User.has_many :blogs, :dependent => :destroy
User.has_one :profile, :dependent => :destroy
User.has_many :galleries, :dependent => :destroy

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
wheels-0.1.30 lib/wheels/active_record_user_extensions.rb
wheels-0.1.28 lib/wheels/active_record_user_extensions.rb
wheels-0.1.27 lib/wheels/active_record_user_extensions.rb
wheels-0.1.25 lib/wheels/active_record_user_extensions.rb
wheels-0.1.24 lib/wheels/active_record_user_extensions.rb
wheels-0.1.23 lib/wheels/active_record_user_extensions.rb
wheels-0.1.22 lib/wheels/active_record_user_extensions.rb
wheels-0.1.21 lib/wheels/active_record_user_extensions.rb
wheels-0.1.20 lib/wheels/active_record_user_extensions.rb
wheels-0.1.19 lib/wheels/active_record_user_extensions.rb
wheels-0.1.18 lib/wheels/active_record_user_extensions.rb
wheels-0.1.17 lib/wheels/active_record_user_extensions.rb
wheels-0.1.16 lib/wheels/active_record_user_extensions.rb
wheels-0.1.15 lib/wheels/active_record_user_extensions.rb
wheels-0.1.14 lib/wheels/active_record_user_extensions.rb
wheels-0.1.13 lib/wheels/active_record_user_extensions.rb
wheels-0.1.12 lib/wheels/active_record_user_extensions.rb
wheels-0.1.11 lib/wheels/active_record_user_extensions.rb
wheels-0.1.10 lib/wheels/active_record_user_extensions.rb
wheels-0.1.9 lib/wheels/active_record_user_extensions.rb