public
Fork of skwp/acts_as_shareable
Description: Github fork of John Duff's plugin at http://agilewebdevelopment.com/plugins/acts_as_shareable
Homepage: http://agilewebdevelopment.com/plugins/acts_as_shareable
Clone URL: git://github.com/IamPersistent/acts_as_shareable.git
molpe (author)
Sun Sep 27 14:30:31 -0700 2009
IamPersistent (committer)
Sun Oct 18 02:17:31 -0700 2009
commit  4c41d7a3726d790db96131540ae60b316b0d73a2
tree    390d351f8d0781f73cdbb7f1bfb6be12169f7ec6
parent  d21505462b291423da5b513f82fb71b78d720d74
name age message
file README Loading commit data...
file Rakefile
directory generators/
file init.rb
file install.rb Wed Jun 03 00:09:06 -0700 2009 Fixed directories [IamPersistent]
directory lib/
directory tasks/
directory test/ Wed Jun 03 00:09:06 -0700 2009 Fixed directories [IamPersistent]
file uninstall.rb Wed Jun 03 00:09:06 -0700 2009 Fixed directories [IamPersistent]
README
ActsAsShareable
===============

Allows for model objects to be shared to other models, the 'sharing' is also associated to a user

== Resources

Install
 * Run the following command:
 
 script/plugin install 
 * There's a generator to create the database migration, but it might not work
 * Create a new rails migration and add the following self.up and self.down methods
 
  class CreateShares < ActiveRecord::Migration
    def self.up
      create_table :shares, :force => true do |t|
        t.column :user_id,            :integer
        t.column :shareable_type,     :string, :limit => 30
        t.column :shareable_id,       :integer
        t.column :shared_to_type,     :string, :limit => 30
        t.column :shared_to_id,       :integer
        t.column :created_at,         :datetime
        t.column :updated_at,         :datetime
      end
    end
  
    def self.down
      drop_table :shares
    end
  end

== Usage
 
 * Make you ActiveRecord model shareable.
 
 class Book < ActiveRecord::Base
   acts_as_shareable
 end
 
 * Share a new book to a group
 
 book = Book.new
 group = Group.new
 book.share_to(group,by_user)
 
 * Can find shared objects by sharable_type, where they are shared, or the user that shared them
 
 Book.find_by_shared_to(group)
 Book.find_shares_by_user(user)

== Credits

Infulenced by plugins and tutorials by Techknow @ juixe.com

== More
jduff@overlay.tv
http://blog.overlay.tv