I've been trying to use put_root_layout inside a controller to no avail, it always falls back to :root. I realised this is because the pipeline has plug :put_root_layout, if I remove that it works fine. However, I want a default for all pages except certain controller actions so I don't want to remove the plug. Should the controller put_root_layout superseede the pipeline one?
#plug :put_root_layout makes put_root_layout do nothing
1 messages · Page 1 of 1 (latest)
controllers should totally be able to put_root_layout and override what's in the pipeline
are you sure you're using it right? can you show us a code example?
Sure, this is in my controller
def solid(conn, _params) do
conn
|> put_root_layout(html: {HappyHippoWeb.Layouts, :solid})
|> put_layout(false)
|> render(:solidapp)
end
When I remove plug :put_root_layout, {HappyHippoWeb.Layouts, :root} from router.ex it works
Interesting enough, if I inspect the conn I see this:
:phoenix_root_layout => %{
:_ => {HappyHippoWeb.Layouts, :root},
"html" => {HappyHippoWeb.Layouts, :solid}
}
root_layout() on that same conn gives {HappyHippoWeb.Layouts, :root}
this is incorrect / deprecated; in your router, change it to: plug :put_root_layout, html: {HappyHippoWeb.Layouts, :root}
Hmm, I used the 1.7 generator for a new project, so I assumed it was up to date, guess not 😄
Thanks!
I think it actually may have changed during a 1.7 point release...