TODO: Write a gem description
Add this line to your application's Gemfile:
gem 'actification'
And then execute:
$ bundle
Or install it yourself as:
$ gem install actification
Create migration for actifications and migrate the database
rails g actification:migration
rake db:migrate
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
- Fork it ( https://github.com/[my-github-username]/actification/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request