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.8 lib/wheels/active_record_user_extensions.rb
wheels-0.1.7 lib/wheels/active_record_user_extensions.rb
wheels-0.1.6 lib/wheels/active_record_user_extensions.rb
wheels-0.1.5 lib/wheels/active_record_user_extensions.rb
wheels-0.1.4 lib/wheels/active_record_user_extensions.rb
wheels-0.1.3 lib/wheels/active_record_user_extensions.rb
wheels-0.1.2 lib/wheels/active_record_user_extensions.rb
wheels-0.1.1 lib/wheels/active_record_user_extensions.rb
wheels-0.1.0 lib/wheels/active_record_user_extensions.rb
wheels-0.0.49 lib/wheels/active_record_user_extensions.rb
wheels-0.0.48 lib/wheels/active_record_user_extensions.rb
wheels-0.0.47 lib/wheels/active_record_user_extensions.rb
wheels-0.0.46 lib/wheels/active_record_user_extensions.rb
wheels-0.0.45 lib/wheels/active_record_user_extensions.rb
wheels-0.0.44 lib/wheels/active_record_user_extensions.rb
wheels-0.0.43 lib/wheels/active_record_user_extensions.rb
wheels-0.0.42 lib/wheels/active_record_user_extensions.rb
wheels-0.0.41 lib/wheels/active_record_user_extensions.rb
wheels-0.0.40 lib/wheels/active_record_user_extensions.rb
wheels-0.0.39 lib/wheels/active_record_user_extensions.rb