Skip to content

Instantly share code, notes, and snippets.

@willrjmarshall
Created June 26, 2014 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willrjmarshall/994038317a952fb97d5c to your computer and use it in GitHub Desktop.
Save willrjmarshall/994038317a952fb97d5c to your computer and use it in GitHub Desktop.
# I used to do this with Rabl
class BaseController < ApplicationController
before_filter @load_active_distributors
def load_active_distributors
# RABL template uses this
@active_distributors ||= Enterprise.distributors_with_active_order_cycles
end
end
# I want to do something similar with ActiveModelSerializers
class Api::EnterpriseSerializer < ActiveModel::Serializer
attributes :active
def active
@active_distributors.include? object
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment