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)