Answer the question
In order to leave comments, you need to log in
Is it possible to do without a bunch of models?
In general, I have a lot of tables in the database.
Each table contains a list of service prices and other data by category.
let's say price_gynecology, price_uzi, etc.
There are 16 such tables in total.
Is it possible somehow not to use 16 models to display data to the user?
Let's say that 1 model has the data of these 16 tables? Or only 16 models to do using ActiveRecord?
Answer the question
In order to leave comments, you need to log in
Most likely your tables are not normalized and contain redundant data.
I would try to make one table for prices and one for categories, with a relationship between them via a foreign key.
Tables, as well as models, are better not to produce without good reasons.
AR means 1 model per 1 table.
I so understand at you the redundant structure of the table. Of course, you need to look at the structure of your application, but as an idea, think in this direction
there is 1 entity "PRICE" it has a table and a model, for example, the structure is:
id | datecreate | author_id etc.
and there is a price table associated with it, where the structure is:
id | price_id | price_type | price
price_id - link
price_type - stores gynecology or uzi and so on, as a number
price - integer (price itself)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question