First this! I had an analog mind, and I didn't know how the files of the app created by rails new were structured. It's all * alphabet *.
I wrote everything on paper. Yes, everything from app to README.md.
I think it looks like this at first. This time, let's check where the main files are located when creating the application that you want to understand first. Other than that, you will gradually understand it later, so don't rush.
app is an abbreviation for application. Of these, the first four you need are assets, controllers, models, and views. Each is a group of files that control page decoration, operations, data, and screen display.
** Contains items related to page decoration. ** ** I think there are 4 folders in assets.
-** config : Contains Javascript settings, etc. - images : Put the images used for embedding etc. - javascripts : Contains the Javascript code. - stylesheets **: Contains CSS.
Contains various controllers that run the application.
-** application_controller : Exists from the beginning. It is a controller common to all applications. - Below **: This is a controller I created.
Contains various models that handle data. ――Basically I make everything myself.
Contains various HTML. The folder name matches the controller name. The users in this come from = users_controller.
The first thing you want to know is routes.rb
Roots, that is, multiple routes. It's like a way to connect things that move apps, such as controllers and models.
What you need to know is migrate
It contains the database design.
These two are used when installing various functions in the application.
--Gemfile: A place to describe and store functions called gems (packaged like apps) --Gemfile.lock: It is regenerated every time you install a gem, and the information (version etc.) of the gem used in this application is displayed and fixed.
This time I organized the location of the files. The first thing I want to remember is only ** 8 **. Assets, controllers, models, views in the app routes.rb (roots) in config migrate in db And Gemfile and Gemfile.lock.
What role file is in which file? I think it will be much cleaner if it can be organized.
Recommended Posts