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

rms.mrcs
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
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

vertexbuffer
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
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49084 226
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

We're in Beta

About us Mission Statement