Week 05, Day 02

What we covered today:

  • Office Visit to Hotels Combined
  • Photos
  • Rails
    • Naming Conventions
    • Helpers
    • CRUD
    • Planets
  • Homework - build a CRUD system like Planets!

Naming Conventions

Models are singular, with a capitalized class name, located in app/models, have an extension of .rb, and inherit from ActiveRecord::Base.

Controllers are plural, with a CamelCase class name, located in app/controllers, have an extension of .rb, and inherit from ApplicationController.

Views are a bit more difficult. They reside in a folder in app/views, the name of that folder comes from the associated controller and is plural. The name of the actual file is the name of the associated action (or method), plus .html.erb. They don't inherit from anything. This may make things clearer...

Type File Name Location Class Name Inherits From
Model planet.rb app/models Planet ActiveRecord::Base
Controllers planets_controller.rb app/controllers PlanetsController ApplicationController
Views index.html.erb app/views/planets N/A N/A