This directory holds different views, which the end user is going to see. The views are again grouped into folders for each component. The views files are in the erb file format embedded Ruby which allows you to write plane old html interspersed with Ruby elements. This contains your environment.
This directory holds your database and database migrations. You need a config. It loads your application environment, code, libraries, and specifies which controllers to load. This holds a list of all the gems that are required for the application.
Running bundle install in your command line will install all the listed gems and dependencies. It separates an application into the following components:. The Models, Views and Controllers will be grouped into a folder named app directory where we spend most of our time coding. This directory holds the logic behind our application. Typically, these files represent either a component of our application, such as a User, Post, or Comment… Each file in models typically contains a different class.
For example, dog. We should be able to read and write to these attributes and this class should also keep track of each instance of dog created, as well as a class method all to return an array of those instances:.
Controllers represent the application logic, generally; the interface and flow of our application. You'll be coding along in this lesson so fork and clone this lab. There are tests to run to make sure your solutions are working. Find the instructions underneath the descriptions for each file you'll be editing.
Take a look at the file structure in this directory. It's okay if it feels overwhelming at first. We're going to walk through the different files and folders and discuss what their responsibilities are.
This holds a list of all the gems needed to run the application. The bundler gem provides us access to a terminal command: bundle install.
Bundler will look in the Gemfile and install any gems, as well as any gem dependencies for this application. Go ahead and enter this command in terminal. It will create a Gemfile. This folder holds our MVC directories - models , views , and controllers. We spend most of our time coding in this directory. This directory holds the logic behind our application.
Typically, these files represent either a component of your application, such as a User, Post, or Comment, or a unit of work. Each file in models typically contains a different class. For example, dog. As you might have guessed, models represent the "M" components of the MVC paradigm.
A config. It specifies to our app handler what files should be run in order to initialize a new server instance of our Sinatra application. The app. There is typically a class, which in this case we will call App , that represents an instance of your application when the server is up and running. Inside of the App class, you can specify your Sinatra application configurations, as well as your routes and controller actions. Then through your controller actions, you would specify which views to be rendered.
The config directory stores our environment.
0コメント