Hello, please i need assistance on how to search records within multiple tables.
I have a transaction table, account table and customer table.
A customer has many accounts and account has many transaction.
I want to be able to search transactions table by either customer name
or account number
.
Please kindly see below the schema for the tables
Transaction
# Transaction Table
schema "transactions" do
belongs_to :account, App.Clients.Account
field :amount, :string
field :transaction_date, :date
timestamps();
end
# Account Table
schema "accounts" do
field :account_number, :string
belongs_to :customer, App.Clients.Customer
has_many :transactions, App.Banking.Transaction
timestamps()
end
# Customer Table
schema "customers" do
field :firstname, :string
field :surname, :string
field :middlename, :string
has_many :accounts, App.Clients.Account
timestamps()
end