10000 GitHub - nicolasva/acts_as_owner: Simple Rails plugin that allows to operate freely on objects which belong to us.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Simple Rails plugin that allows to operate freely on objects which belong to us.

License

Notifications You must be signed in to change notification settings

nicolasva/acts_as_owner

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ActsAsOwner
===========

Provides to a user the ability to self-query about the possession of a given resource or a given account.

Any resources belonging to an other resource which is owned by the user are considered such as owned by this user too.


Install
=======

To install as a plugin:

  script/plugin install git://github.com/cyril/acts_as_owner.git


Example
=======

  class User < ActiveRecord::Base
    acts_as_owner :categories, :articles, :comments
  end

  # Considering this article:
  article = current_user.articles.first

  # We can see that:
  current_user.owns? article                     # => true
  current_user.owns? article.user                # => true

  # Now, check if its first comment is ours:
  current_user.owns? article.comments.first.user # => false

  # But even if it is not, this comment is a child of our article, so:
  current_user.owns? article.comments.first      # => true


Copyright (c) 2009 Cyril Wack, released under the MIT license

About

Simple Rails plugin that allows to operate freely on objects which belong to us.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0