I have following two Serializer class. In index controller I want skip loading project_products, only show/edit method I want to fetch project_product details.
class ProjectSerializer < ActiveModel::Serializer
attributes :id, :name, :category, :project_category_id, :status, :description
has_many :project_products
end
class ProjectProductSerializer < ActiveModel::Serializer
attributes :id, :name, :quantity
end
Controller:
def index
respond_with @projects
end
def load_projects
@projects = current_organization.projects.includes(:project_category)
end