Skip to content

Commit

Permalink
Merge pull request #757 from Ada-Developers-Academy/be/view-file-crea…
Browse files Browse the repository at this point in the history
…tion-explanation

index.html.erb file creation
  • Loading branch information
CheezItMan authored Apr 22, 2020
2 parents e5d9989 + d4c3d9a commit 42e503d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion 08-rails/ERB-and-Layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ class BooksController < ApplicationController
end
end
```
... and inside of `app/views/books` ... there is a view file named after the index action. `index.html.erb`. This is an example of how Ruby favors **convention over configuration**. The default view for an action/method is named after it and stored in a folder named after the class.
... and inside of `app/views/books` ... we will create a file named after the index action: `index.html.erb`.

We manually added the `index` action to our `Books` controller and thus needed to manually add the corresponding view. Had we created the index action using the rails console with the command `rails generator controller Books index`, there would already be a file in the views directory named after the index action.

This is an example of how Ruby favors **convention over configuration**. The default view for an action/method is named after it and stored in a folder named after the class.

```html
<h1>Books#index</h1>
Expand Down

0 comments on commit 42e503d

Please sign in to comment.