Change layout inside of action

How can I change the layout in the action method?

def show

if(params[:id] > 0)
layout :layout1
else
layout :default
end

end

Is this possible?

Have a look at this guide:

Please check to see if your questions are answered in the guides before
posting here.