DEV Community

n350071🇯🇵
n350071🇯🇵

Posted on

3

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)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →