Created
June 26, 2014 00:27
-
-
Save willrjmarshall/994038317a952fb97d5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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