Answer the question
In order to leave comments, you need to log in
How to organize a CRUD application with multiple tables on Rails?
There is a MySQL database with several tables (task, comment, issue) and relationships.
There is a Rails application that connects to this database.
You need a window that will display a list of tasks (something like a task manager). Here is the data from all the tables. By clicking on a line, details should open (show/edit). And then if through f. I will write down the data in different tables. But if I display the main view via find_by_sql and then search through all tables via join, then the row does not have an id and I cannot open the show/edit action. Or how to display data in one table through each from several tables?
Maybe I chose the wrong direction...? Can you advise how to organize it better?
Do you need separate models/controllers for each table? Do I need to describe all the foreign_keys and stuff... or is self.table_name = 'table_name' sufficient?
Answer the question
In order to leave comments, you need to log in
You need to smoke in the direction of the nested model form
Models for each table will still have to be done, including for validation. Controller is not required.
foreign_key for the integrity of relationships at the database level is not directly related to the form, but in general it is better to use it than not.
If we are talking about pure CRUD, then I advise you to look towards the rails + netzke + extjs bundle quickly and efficiently.
netzke.org website has a demo, you can see how it looks and works.
Again, it all depends on your tasks, if a lot of custom logic is supposed to be behind CRUD, then it’s easier to write from scratch than to customize a ready-made solution.
As for your question about the non-receiving SQL queries, a set of words has been written. If you want advice, show what's going on in your models, table relationships, describe the structure of the database and give a query that doesn't work the way you want.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question