Reputation: 7338
I'm new to Ruby, and learning Ruby on Rails.
I saw this code:
class DemoController < ApplicationController
layout false
def index
end
end
What does layout false
mean?
I've seen the include
keyword, but I've never seen layout
before. Is a Rails specific keyword?
What exactly does the 'keyword space keyword' form mean in Ruby, and is there a language specification? And can I create my own 'keywords'?
Upvotes: 1
Views: 436
Reputation: 266
layout
isn't a keyword. layout false
is the same as layout(false)
. The parentheses are optional for method calls in Ruby.
See the layout
documentation for details of the layout()
method in Rails.
Upvotes: 2
Reputation: 10043
The view in ruby on rails applications takes the layout defined in layouts/application.html.erb by default. In case you want to use any different layout for specific views, you can change the layout parameter. Here the
views under Demo controller will not use the default layout
. You can also use layout parameters while rendering templates/view files. These are pre-defined keywords and in case you are looking for own set of keywords. You have to override these, but it's not a best practice considering ruby's "convention over configuration". For details can check Rails layout guides
Upvotes: 0