Project

activityko

0.0
No commit activity in last 3 years
No release in over 3 years
An activity logger for rails 5 that provides view helpers to render basic format of activity.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.14
~> 10.0
~> 3.0

Runtime

 Project Readme

Activityko

An activity logger for rails 5. It provides view helpers to render basic format of activity.

Installation

gem 'activityko'

And then execute:

$ bundle

Then generate model and migration files

$ rails g activityko:install
$ rake db:migrate

Usage

Owner of the Activity

Add this to your User model

class User < ApplicationRecord
  act_as_loggable
end

This will add create_activity(action, options={}) method to your model

Object of the Activity

Then, make all possible objects of Activity an activty object.

class Group < ApplicationRecord
  act_as_activity_object
end
class Location <ApplicationRecord
  act_as_activity_object
end

or

class ApplicationRecord < ActiveRecord::Base
  act_as_activity_object
end

An activity_name method is added to all activity objects.

The User model is also an activity object.

View Helpers

User basic_activity method to display an activity

<% @activities.each do |a| %>
  <%= basic_activity %>
<% end %>

or basic_activity also accepts block

<% basic_activity @activity do%>
  <%= activity_subj %>
	<%= activity_action %>
	<%= activity_dir_obj %>
	<%= activity_prep %>
	<%= activity_prep_obj %>
	<%= activity_time %>
<% end %>

You can customize each activity output by using render_activity. Inspired by Public Activity gem. Check it out.

  <%= render_activity @activity%>

File structure

app:
  views:
    activities:
      <activity_obj_model>:
        _<activity_action>.html.erb

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/neume/activityko. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.