Coder Social home page Coder Social logo

actification's Introduction

Actification

TODO: Write a gem description

Installation

Add this line to your application's Gemfile:

gem 'actification'

And then execute:

$ bundle

Or install it yourself as:

$ gem install actification

Database setup

Create migration for actifications and migrate the database

rails g actification:migration
rake db:migrate

Usage

TODO: Write usage instructions here

# app/actifications/user_actification.rb
class ArticleActification < Actification::Base
  default from: current_user

  def publish_article(article)
    actice(to:       article.active_user,
           body:     "#{article.auther} published 「#{article.title}」",
           link_url: article_path(article))
  end

  def delete_article(article)
    actice(to:   article.watch_user,
           from: article.user_id
           body: "#{article.auther} deleted 「#{article.title}」")
  end
end
# app/controllers/articles_controller.rb
class ArticlesController < ApplicationController

  def create
    @article = Article.new(article_params)

    if @article.save
      ArticleActification.publish_article(@article)
      redirect_to @article
    else
      render :new
    end
  end
end
# app/controllers/top_controller.rb
class TopController < ApplicationController
  def index
    @actifications = Actification::Model.all
  end
end
# config/initializers/actification.rb
Actification.configure do |config|
  config.cleaner = true

  # To use root_path in xxxActification class
  config.include Rails.application.routes.url_helpers
end
# migration.rb
class Actification::Base < ActiveRecord::Migration
  def change
    create_table :actifications do |t|
      t.integer :to,           null: false
      t.integer :from
      t.string  :body,         null: false, limit: 512
      t.string  :link_url
      t.boolean :read,         null: false, default: false
      t.string  :type,

      t.timestamps
    end

    add_index :actifications, [:read, :to]
  end
end

Contributing

  1. Fork it ( https://github.com/[my-github-username]/actification/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

actification's People

Contributors

kyuden avatar

Watchers

 avatar

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.