Acts As Flaggable plugin
Plugin details
Documentation
Install the plugin:
ruby script/plugin install http://svn.baconbear.com/rails_plugins/acts_as_flaggable/trunk
Create a new rails migration and add the following self.up and self.down methods
def self.up create_table :flags, :force => true do |t| t.column :flag, :string, :default => "" t.column :comment, :string, :default => "" t.column :created_at, :datetime, :null => false t.column :flaggable_id, :integer, :default => 0, :null => false t.column :flaggable_type, :string, :limit => 15, :default => "", :null => false t.column :user_id, :integer, :default => 0, :null => false end add_index :flags, ["user_id"], :name => "fk_flags_user" end def self.down drop_table :flags end
Make you ActiveRecord model act as flaggable.
class Model < ActiveRecord::Base acts_as_flaggable end
Add a flag to a model instance
model = Model.new flag = Flag.new flag.flag = 'Some flag' model.flags.add_flag flag
When a flag is added via add_flag, flagged(flag, flag_count) is called on the flaggable model. This allows the model to perform certain operations if the number of flags reaches a certain point. For example, you may want to mark a Post as deleted if a Post receives too many "spam" flags
Each flag reference flaggable object
model = Model.find(1) model.flags.get(0).commtable == model
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | Back in time (2 older versions) | Last edited by: scott, 3 months ago

