Chapter 11

Layoutを変更する

toyoshi
toyoshi
2021.12.31に更新

routerで変更する方法。pipelineを作って、pipe_throughで加える

  pipeline :authentication_layout do
    plug :put_root_layout, {Blog.LayoutView, :authentication}
  end

  scope "/", Blog do
    pipe_through [:browser, :redirect_if_user_is_authenticated, :authentication_layout]

    get "/users/register", UserRegistrationController, :new
    post "/users/register", UserRegistrationController, :create
    get "/users/log_in", UserSessionController, :new
    post "/users/log_in", UserSessionController, :create
    get "/users/reset_password", UserResetPasswordController, :new
    post "/users/reset_password", UserResetPasswordController, :create
    get "/users/reset_password/:token", UserResetPasswordController, :edit
    put "/users/reset_password/:token", UserResetPasswordController, :update
  end