Plugins - Acts as Network

StarAdd to favorites

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!

Federico Feroldi

http://www.pixzone.com/blog/16/acts_as_network-plugin-2/

http://svn.pixzone.com/svn/public/plugins/acts_as_network/

Rails' (MIT)

  • Currently 3.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Model

Tags

Comments

Add a comment
Dissapointed! 30 Jan 2007

Repository is 404

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?