DEV Community

n350071πŸ‡―πŸ‡΅
n350071πŸ‡―πŸ‡΅

Posted on

Specify layout file in Rails Views

1. At the Controller level

class PostsController < ApplicationController
  layout "index_layout" only [:index]
  layout "nomal_layout" expect [:index]
end

2. At the action level

class PostsController < ApplicationController
  if @post.save?
    render layout: "success_layout"
  else
    render :new, layout: false
 end
end

πŸ”— Parent Note

Top comments (0)