Forum: Ruby on Rails acts_as_network plugin

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Federico F. (Guest)
on 2006-03-04 00:58
Hi everybody,
I just released by first Rails plugin! :)
Even if it's very simple, I hope that somebody will find it useful!

You can install it with the 'plugin' script:

$ script/plugin install
http://svn.pixzone.com/svn/public/plugins/acts_as_network

Anybody knows how to add my public svn repository to the plugin
repositories list?

enjoy! :)

acts_as_network
===============

 This module adds the networking behaviour to an ActiveRecord model.
 The networking logic will use a support table to create n:m
associations
 between objects.

 Example:

 class User < ActiveRecord::Base
   acts_as_network :join_table => friends,
      :source_key => :id_user,
      :destination_key => :id_friend
 end

 first = users(:first)
 second = users(:second)

## Add a new connection

 first.connections << second

## Associate a role to a connection if you
## have the 'role' column in the join table

 first.connections.push_with_attributes(second, :role => 2)
 role = first.connections.find(second.id).role

## check for inclusion

 first.connections.include?(second)

Enjoy!

Author:
   Federico F.
   removed_email_address@domain.invalid

Released under the same license as Ruby. No Support. No Warranty.
This topic is locked and can not be replied to.