thojanssens1

thojanssens1

Adding a query string to a redirection

Hi

How can I add a query string like ?foo=bar?

    redirect(conn,
      to:
        Routes.user_path(
          conn,
          :show_user,
          some_param,
          other_param
        )
    )

I can’t find an option for adding a query string in the redirect helper.

Marked As Solved

LostKobrakai

LostKobrakai

That’s because redirect works with any path/url and get params are just a part of them:

        Routes.user_path(
          conn,
          :show_user,
          some_param,
          other_param,
          foo: "bar"
        )

Also Liked

LostKobrakai

LostKobrakai

if(is_active, do: 1, else: 0)

The above is hardly longer than something akin to a ternary operator, but using the default elixir keyword syntax. Meaning nothing had to be created to support it.

Last Post!

OvermindDL1

OvermindDL1

active: is_active && 1 || 0

This is not a recommended pattern, and it can fail in a couple of surprising ways (specifically if the 1 in the above example where nil or false because it interprets it as active: (is_active && 1) || 0), but it’s the bash’ism style, that works in Elixir too. ^.^;

Where Next?

Popular in Questions Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
joeerl
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
marius95
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
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
joeerl
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
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New

We're in Beta

About us Mission Statement