-
Notifications
You must be signed in to change notification settings - Fork 0
Ruby on Rails plugin that allows for associating objects with users, verifying this association, and automatically setting the default scope to find according to the current logged in user.
License
ChapterHouse/acts_as_owned
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
ActsAsOwned =========== The ActsAsOwned plugin allows for associating objects with users, verifying this association, and automatically setting the default scope to find according to the current logged in user. Note: This plugin depends on the restful_authentication plugin to access the current user. Example ======= Assuming that you could some how access the current logged in user at the model level, you could write something like this for your class. class OwnedItem < ActiveRecord::Base default_scope :conditions => {:user_id => current_user ? current_user.id : nil} belongs_to :user validates_presence_of :user validates_associated :user before_validation_on_create, Proc.new { |record| record.user = current_user } end Some of this could also be handled in the controller. Specifically the association of the current user with the record and the scoping of the finds. However, instead of doing all of this, you could just use class OwnedItem < ActiveRecord::Base acts_as_owned end Short sweet and to the point. Copyright (c) 2009 Frank Hall, released under the MIT license
About
Ruby on Rails plugin that allows for associating objects with users, verifying this association, and automatically setting the default scope to find according to the current logged in user.
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published