Hizqeel
Render Expects Template to be a String
Hi, I am writing an authentication plug, upon failure I am rendering to 403 error page
case claims do
{:ok, claims} ->
conn
|> put_status(200)
_ ->
conn
|> render("forbidden.html")
|> halt()
end
It gives me this error
** (ArgumentError) render/2 expects template to be a string, got: %Plug.Conn{adapter: {Plug.Cowboy.Conn, :...}, assigns: %{}
I don’t know what I am doing wrong here, Any help would be highly appreciated!
Marked As Solved
Hizqeel
As I was rendering the user to error page so what I did is create a render function in View and render template there:
def render("403.html", _assigns) do
render("forbidden.html", %{})
end
and in my authentication pipe:
case claims do
{:ok, claims} ->
conn
|> put_status(200)
_ ->
conn
|> put_status(403)
|> put_view(MyAppWeb.PageView)
|> render("403.html")
|> halt()
end
1
Also Liked
hauleth
Are you sure you are using correct render/2 function? Especially as in this case you should use put_view/2 or render/3.
1
Popular in Questions
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
Hello everyone,
I try to use an Javascript Event Handler in my root.html.leex file.
Therefore I created a function in the app.js file: ...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
Other popular topics
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Phoenix 1.4.0 released
Phoenix 1.4 is out! This release ships with exciting new features, most notably
with HTTP2 support, improved deve...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









