GithubHelp home page GithubHelp logo

can_flag's Introduction

Can Flag
=================
Strongly inspired by acts_as_flaggable.
Intended to allow your users to flag content as inappropriate, and set up some ways for you 
to deal with the content.

== Resources

Install

1. Download the tarball from github, or, clone the repository and symlink it into your application.
   Yes, I'm serious.
  
2. $ script/generate can_flag flags

   This will create the following files:
     app/controllers/flags_controller.rb
     spec/helpers/flags_controller_spec.rb
     app/helpers/flags_helper
     db/migrate/flags_migration.rb

3. Modify any content model with
  
   class Article < ActiveRecord::Base
     can_be_flagged
   end
   
   You can also add a callback
   
   class Article
     can_be_flagged
     def after_flagged
       # send an email
       # delete this post
       # suspend the owner of the post if the flags.size > 3
       # suspend the owner of the post if their total flags count > 5
     end
   end

4. Modify your user model with
 
   class User < ActiveRecord::Base
     can_flag     
   end

5. Usage

   article = Article.find(4)
   current_user.flags.create :flaggable => article

 

 * 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

can_flag's People

Contributors

courtenay avatar zachinglis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

can_flag's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.