A
A
Alexey Kot2018-11-16 11:56:34
Database design
Alexey Kot, 2018-11-16 11:56:34

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

2 answer(s)
I
Ilya Ponomarev, 2018-11-16
@ilyario

Use the has_and_belongs_to_many link doesn't work?
rusrails.ru/active-record-associations#svyaz-has_a...

R
Roman Mirilaczvili, 2018-11-16
@2ord

@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 question

Ask a Question

731 491 924 answers to any question