No release in over 3 years
Low commit activity in last 3 years
Rails gem to allowing models to be events for full calendar
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Acts As Full Calendar Event

Gem to allow any model to work as event for FullCalendar

Acts As Full Calendar Event is a Ruby Gem specifically written for Rails/ActiveRecord models. The main goals of this gem are:

  • Allow any model to be used as event for FullCalendar.
  • Provide easy-to-use and reusable methods to perform searchs and filter data.
  • Serialize data for calendar.

Installation

Supported Ruby and Rails versions

  • Ruby >= 2.3.0
  • Rails >= 4

Install

Just add the following to your Gemfile to install the latest release.

gem 'acts_as_full_calendar_event', '1.0.1'

And follow that up with a bundle install.

Usage

class SomeEvent < ActiveRecord::Base
  acts_as_full_calendar_event field_start: :calendar_inicio,
    field_end: :calendar_fin,
    field_title: :calendar_title,
    field_color: "#FF0000",
    field_text_color: :calendar_text_color,
    field_url: :url_for_calendar,
    field_link_data_toggle: :calendar_link_data_toggle,
    field_link_data_target: :calendar_link_data_target,
    method_fields: :for_calendario,
    method_filter_category: :within_calendar_category,
    method_filter_user: :by_user_id,
    method_filter_date: :filter_by_date,
    method_categories: :categories,
    field_category_class: :category_class
end

Calendar service

Initialize as

ActsAsFullCalendarEvent::Calendar.new(params: params).filter

params is a hash that must contain: · start (Date) · end (Date) and can also contain: · user_id · Categories

Categories hash has the following structure:

{ "CategoryClassName1" => [id1, id2], "CategoryClassName2" => [id1, id2] }

If some category class doesn't appear as hash key it will be ignored.

filter method returns an ActiveRecord::Relation with all matching events

Testing

All tests follow the RSpec format and are located in the spec directory. They can be run with:

rake spec

License

Acts as votable is released under the MIT License.