Rails promotes "convention over configuration". Default rendering is an excellent example of this. By default, controllers in Rails automatically render views with names that correspond to valid routes. For example, if you have this code in your
BooksController
class:class BooksController < ApplicationController
end
And the following in your routes file:
resources
:books
And you have a view file app/views/books/index.html.erb
:
<h1>Books are coming soon!</h1>
Rails will automatically render
app/views/books/index.html.erb
when you navigate to /books
and you will see "Books are coming soon!" on your screen.
No comments:
Post a Comment