Rails doesn't need an index method in a controller?

I noticed that the index view is directed correctly, even if the index of the controller method is missing.

As an example, routes.rb has this route

 AppName::Application.routes.draw do get 'about' => "about#index" end 

My controller looks like this without an index ( def index end )

 class AboutController < ApplicationController end 

and I have a view called index.html.erb in the views / about folder

What's going on here? Is this a case of rail magic where they automatically show a view, even if there is no controller method? I could not find documentation on this ...

+8
ruby-on-rails ruby-on-rails-3
source share
1 answer

If you have a view file, it will continue and will be displayed implicitly, as described here

See also this SO thread on how Rails maps your view files and controller actions .

+10
source share

All Articles