Skip to content

Instantly share code, notes, and snippets.

@jesuslerma
Created October 15, 2015 15:16
Show Gist options
  • Save jesuslerma/449649ff8d30bc51db45 to your computer and use it in GitHub Desktop.
Save jesuslerma/449649ff8d30bc51db45 to your computer and use it in GitHub Desktop.
Como yo veo la solucion
def index
invoices_by_type
end
def sales
invoices_by_type
end
def expenses
invoices_by_type
end
def payroll
invoices_by_type
end
def invoices_by_type
type = request.action
case type
when "sales"
invoices = current_company.ingresos
when "expenses"
invoices = current_company.egresos
when "payroll"
invoices = current_company.payroll
else
invoices = current_company.all_invoices
end
response = {
invoices: invoices,
pagination: meta_pagination(invoices)[:pagination]
}
render json: response
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment