I’m new in the world of Ruby on Rails. I have some problems to solve before start to build a store-like web application.
I’m following instructions written in the book “Agile Web Development with Rails” so I decided to use sqlite too…
…but I have already represented the scenario via ER Diagrams and now I don’t know how to bring it on rails.
In the early chapters of the book, it uses the scaffold command to create the table “Product”. But this command creates model, view, controller and test for every table I want to represent.
Is it the right way to proceed? Or is there a way to build all my tables before I start to create mvc I need?
Try the Guides to Ruby On Rails:
http://guides.rubyonrails.org/getting_started.html
It’s generally easier to understand (in my opinion) than the Agile book.
The easiest way to create your tables is by using Rails migrations.
The easiest way to create migrations with the related models, views, and controllers is:
That command will print what it’s doing. Take a look in those files.
If you have many tables, yes the typical way is to generate many scaffolds, for example:
In your comment you ask about a type_of_product table. For tables like these, yes it’s fine to skip the scaffold (for example because you don’t need a controller) and instead just generate a migration:
Heads up that Rails does odd things with the word “type”. When I did a table like that, I found it easier to start with the main word then use the word “kind” like this: