How to Begin a MVC Ruby on Rails project
- rails g model
- rails g scaffold ClassName attr_1:datatype attr_2:datatype
- eg rails g scaffold Entry meal_type:string calories:integer proteins:integer carbs:integer fats:integer
- created_at & updated_at column is created automatically+
- after creating the scaffold, there is a migration file in db/migrate which needs to be dealt with
- using rails db:migrate will create the table
- after creating the scaffold, there is a migration file in db/migrate which needs to be dealt with
- launch the app with rails s
- Use "bundle add name" or add to the "Gemfile" like a package json
- just call "bundle" to do like a "npm install"
- Inside of the config/routes.rb
- root to: "entries#index"
- will route to the entries controller's index action
- app/controllers/entries_controller.rb
- Add responsive viewport meta tag
- and stylesheet from the starter template
- to app/views/layouts/application.html.erb
- name file starting with _ like "_header.html.erb"
- then use <%= render "shared/header" %> to render it out in html
- <%= link_to "Create a New Entry", new_entry_path, class: "button is-success" %>
- link_to "Words to show", rails path, class: "classname"
- Added this time_format.rb in config/initializers
- provides a new function upon app startup
- use <%= params %> to show the params of that page, such as what controller, view and ID are active