Reputation: 5325
In a Rails 4 app I am trying to set the layout to false
or nil
. I tried this from inside my controller:
render :layout => false
But that gives this error:
undefined method `render'.
How can I stop this controller from using the default layout file?
Upvotes: 5
Views: 4941
Reputation: 38645
To disable layout for a controller:
class FooController < ApplicationController
layout false
...
end
Upvotes: 8
Reputation: 53018
class FoosController < ApplicationController
layout false ## Note it is not within any action
def create
...
end
...
end
class FoosController < ApplicationController
...
def show
...
render layout: false
end
...
end
Upvotes: 6
Reputation: 5598
I believe what you are looking for is to render nothing for a particular method (action) in a controller. This should work based on the output you linked to in the pastie under @vee's answer:
def new
# code for the sessions#new controller#method
render nothing: true
end
EDIT: This answer assumes that you do not want to render your actual view template ... if you really do not want to render a layout (versus a view template), @vee's response is the one.
Upvotes: 0