Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ActiveModel Serializer for json response. #31

Open
kuldeepaggarwal opened this issue Apr 3, 2016 · 0 comments
Open

Use ActiveModel Serializer for json response. #31

kuldeepaggarwal opened this issue Apr 3, 2016 · 0 comments

Comments

@kuldeepaggarwal
Copy link
Contributor

In app/serializers/fullcalender_engine/event_serializer.rb

module FullcalendarEngine
  require 'active_model_serializers'
  class EventSerializer < ActiveModel::Serializer
    attributes :id, :title, :description, :start, :end, :allDay, :recurring

    def description
      object.description || ''
    end

    def start
      object.starttime.iso8601
    end

    def end
      object.endtime.iso8601
    end

    def allDay
      object.all_day
    end

    def recurring
      object.event_series_id?
    end
  end
end

In fullcalendar_engine.gemspec:

s.add_dependency "active_model_serializers", ">= 0.9.4"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant