Module: Merb::Authentication::Mixins::UserBelongsToSite
- Defined in:
- lib/merb_auth_slice_multisite/mixins/user_belongs_to_site.rb,
lib/merb_auth_slice_multisite/mixins/user_belongs_to_site/dm_user_belongs_to_site.rb
Overview
This mixin provides basic user authentication by a site_id.
Added properties:
:site_id, Integer
Added Relationships
belongs_to :site
Added Validations
validates_present :site_id
validates_is_unique :login, :scope => :site_id
validates_is_unique :email, :scope => :site_id
To use it simply require it and include it into your user class.
class User
include Authentication::Mixins::UserBelongsToSite
end
OR I RECOMMEND recommend that you put it in your application under merb/merb-auth/setup.rb so it looks like this: # require ‘merb-auth-more/mixins/salted_user’ # Merb::Authentication.user_class.class_eval{ # include Merb::Authentication::Mixins::SaltedUser # include Merb::Authentication::Mixins::UserBelongsToSite # }
Defined Under Namespace
Modules: ClassMethods, DMClassMethods, InstanceMethods
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/merb_auth_slice_multisite/mixins/user_belongs_to_site.rb', line 33 def self.included(base) base.class_eval do include Merb::Authentication::Mixins::UserBelongsToSite::InstanceMethods extend Merb::Authentication::Mixins::UserBelongsToSite::ClassMethods path = File.(File.dirname(__FILE__)) / "user_belongs_to_site" if defined?(DataMapper) && DataMapper::Resource > self require path / "dm_user_belongs_to_site" extend(Merb::Authentication::Mixins::UserBelongsToSite::DMClassMethods) elsif defined?(ActiveRecord) && ancestors.include?(ActiveRecord::Base) require path / "ar_user_belongs_to_site" extend(Merb::Authentication::Mixins::UserBelongsToSite::ARClassMethods) elsif defined?(Sequel) && ancestors.include?(Sequel::Model) require path / "sq_user_belongs_to_site" extend(Merb::Authentication::Mixins::UserBelongsToSite::SQClassMethods) end end # base.class_eval end |