I have a controller like this :
def index
@invoices = current_company.invoices.order(billed_at: :desc)
@user_invoices = current_user.invoices.order(billed_at: :desc)
@all_invoices = (@invoices + @user_invoices).sort_by {|a| a.created_at}.reverse
end
In my view, I would like to separate the invoices from user and invoices, something like :
- @all_invoices.each do |invoice|
- if invoice.user?
= invoice.id
= invoice.number
But I don't get the how to know if my invoice is from the User table or the Invoice table, how can I check that ?
Aucun commentaire:
Enregistrer un commentaire