We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Good Day :),
class Bank < ApplicationRecord has_many :accounts has_many :customers, through: :accounts end class Customer < ApplicationRecord has_one :account has_one :bank, through: :account end class Account < ApplicationRecord belongs_to :bank belongs_to :customer end
Since, there is no bank_id in customers table, how can I add sequential_id to Customer model and scope it the Bank model?
bank_id
sequential_id
The text was updated successfully, but these errors were encountered:
It appears your last class should be Account and not Customer doesn't?
Sorry, something went wrong.
Yes, it was a typo. But the issue remains
@uxxman I'm having a similar requirement currently and created a prototype implementation. In your case, the following might work:
In your Gemfile:
Gemfile
gem 'sequenced', github: 'phylor/sequenced', branch: 'features/scope-across-relations'
# Customer delegate :bank_id, to: :account acts_as_sequenced scope: 'account.bank_id'
If there is interest of @derrickreimer or others, we could work on a pull request implementing this properly.
@phylor Send over a PR and a test and I'll get it merged and released.
I guess we'd want to account for possibly multiple join tables too?
No branches or pull requests
Good Day :),
Relations:
Problem
Since, there is no
bank_id
in customers table, how can I addsequential_id
to Customer model and scope it the Bank model?The text was updated successfully, but these errors were encountered: