Skip to content

Instantly share code, notes, and snippets.

@krokrob
Created August 28, 2019 22:04
Show Gist options
  • Save krokrob/d7788b8da4696844acf01339fdce036a to your computer and use it in GitHub Desktop.
Save krokrob/d7788b8da4696844acf01339fdce036a to your computer and use it in GitHub Desktop.

Rails flow

Route

You want a route to the url /restaurants to display the list of your restaurants.

# config/routes.rb
resources :restaurants, only: [:index]

Now you can access the url /restaurants.

Controller

The route you just design points to the RestourantController and the action #index, that's the Rails convention. Generate the controller from the terminal, don't forget the s at the end of the controller's name:

rails g controller restaurants

Then add the action #index:

# app/controllers/restaurants
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment