This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 4c41d7a3726d790db96131540ae60b316b0d73a2
tree 390d351f8d0781f73cdbb7f1bfb6be12169f7ec6
parent d21505462b291423da5b513f82fb71b78d720d74
tree 390d351f8d0781f73cdbb7f1bfb6be12169f7ec6
parent d21505462b291423da5b513f82fb71b78d720d74
| name | age | message | |
|---|---|---|---|
| |
README | ||
| |
Rakefile | ||
| |
generators/ | ||
| |
init.rb | ||
| |
install.rb | Wed Jun 03 00:09:06 -0700 2009 | |
| |
lib/ | ||
| |
tasks/ | ||
| |
test/ | Wed Jun 03 00:09:06 -0700 2009 | |
| |
uninstall.rb | Wed Jun 03 00:09:06 -0700 2009 |
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







