Skip to content

Instantly share code, notes, and snippets.

@yaymukund
Last active December 22, 2015 07:29
Show Gist options
  • Save yaymukund/6438345 to your computer and use it in GitHub Desktop.
Save yaymukund/6438345 to your computer and use it in GitHub Desktop.
class BillingController < ApplicationController
def index
@companies = Company.includes(:transactions).merge(Transaction.pending)
end
end
<% @companies.each do |c| %>
<p><%= c.fantasy_name %> has <%= pluralize(c.transactions.pending.count, 'transaction')%> pending.</p>
<% end %>
class Transaction < ActiveRecord::Base
scope :pending, -> { where(payment_status: 'pending') }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment