Answer the question
In order to leave comments, you need to log in
How to make a similar model in Ruby on Rails?
Hello! I apologize in advance for not being able to write a clear title.
The essence of the problem. It is necessary to implement the following data model
There is an entity Company
Different companies can submit (have) different types of taxes , for example, some of these:
STS
Transport tax
Property tax
VAT
Salary
and other
Input data for each tax tax may differ, for example, in one you need to fill
Accrued Paid Date Balance, otherwise two more fields will be added.
On the front-end, during the creation of a company, I want to check off which taxes the company will submit and then enter data related to a particular company for each tax.
And then use queries like
Company.tax
=> nds, transport, usn
(to see what taxes the company pays in general)
And be able to see the company data for each tax using a similar request
Company.tax.nds
And so far I can’t figure out how to such to implement by means of ActiveRecord. Help me please.
Answer the question
In order to leave comments, you need to log in
Use the has_and_belongs_to_many link doesn't work?
rusrails.ru/active-record-associations#svyaz-has_a...
@company.taxes
BaseTax base model: tax_type:string, tax_id, company_id
polymorphic: true
https://guides.rubyonrails.org/association_basics....
+
https://medium.freecodecamp.org/single-table-inher. ..
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question