3 controller what is it doing?


i dont understand the empty function

class PagesController < ApplicationController

def home


what is def home end doing where is the rest of the code inside?


Hi @mbrown1,

The def home part is simply telling Rails that the home route does exist. There are three things Rails needs before you can go to a route:

  1. A route in config/routes.rb
  2. A [route].html.erb file in app/views/[controller]
  3. A def [route] in the controller's file.

If Rails doesn't have all three of those, it will throw an error and not show you the page. So even if you only have an empty function, it still has to exist for you to be able to view the page :slight_smile:


thank you that makes sense now