GoulvenClech

GoulvenClech

Since updates, no route found for POST after Form submitted

Hello everyone,

I tried today to update the mix dependencies of the project, which led to a bug on our forms:

When I click on the confirm button (Surface’s component), the page url updates to add a “#” and the " no route found for POST [current URL path] (MyAppWeb.Router)" error appears. I did not touch the forms, they worked before the update, and here is an example handle_event/3 function linked to one of the forms:

  @impl true
  def handle_event("submit", %{"property" => property_params}, socket) do
    save_property(socket, socket.assigns.action, property_params)
  end

  defp save_property(socket, :edit, property_params) do
    case Properties.update_property(socket.assigns.property, property_params) do
      {:ok, _property} ->
        {:noreply,
         socket
         |> put_flash(:info, "Propriété mise à jour avec succès")
         |> push_redirect(to: socket.assigns.return_to)}

      {:error, %Ecto.Changeset{} = changeset} ->
        {:noreply, assign(socket, :changeset, changeset)}
    end
  end

Here is the list of updated dependencies, my main suspect is surface 0.9.1 => 0.11.0 (minor), but they don’t indicate breaking change on their doc. :

Summary

Upgraded:
appsignal 2.4.3 => 2.7.5
appsignal_phoenix 2.2.1 => 2.3.3
appsignal_plug 2.0.12 => 2.0.14
cachex 3.4.0 => 3.6.0
castore 0.1.20 => 0.1.22
commanded 1.4.1 => 1.4.2
cowboy 2.9.0 => 2.10.0
cowlib 2.11.0 => 2.12.1
credo 1.6.7 => 1.7.0
db_connection 2.4.3 => 2.5.0
decimal 2.0.0 => 2.1.1
earmark 1.4.34 => 1.4.38
earmark_parser 1.4.29 => 1.4.32
ecto 3.9.4 => 3.10.2
ecto_sql 3.9.2 => 3.10.1
esbuild 0.6.0 => 0.7.1 (minor)
eventstore 1.4.1 => 1.4.2
excoveralls 0.15.1 => 0.16.1 (minor)
finch 0.14.0 => 0.16.0 (minor)
floki 0.34.0 => 0.34.3
gen_stage 1.1.2 => 1.2.1
geo 3.4.3 => 3.5.1
geo_postgis 3.4.2 => 3.4.3
gettext 0.20.0 => 0.22.2 (minor)
goth 1.3.1 => 1.4.1
libcluster 3.3.1 => 3.3.3
mint 1.4.2 => 1.5.1
nimble_options 0.5.2 => 1.0.2 (major)
nimble_pool 0.2.6 => 1.0.0 (major)
oban 2.13.6 => 2.15.2
phoenix 1.6.15 => 1.6.16
phoenix_ecto 4.4.0 => 4.4.2
phoenix_html 3.2.0 => 3.3.1
phoenix_live_dashboard 0.7.2 => 0.8.0 (minor)
phoenix_live_view 0.18.3 => 0.19.3 (minor)
phoenix_pubsub 2.1.1 => 2.1.3
phoenix_template 1.0.0 => 1.0.1
plug 1.14.0 => 1.14.2
plug_cowboy 2.6.0 => 2.6.1
plug_crypto 1.2.3 => 1.2.5
postgrex 0.16.5 => 0.17.1 (minor)
pow 1.0.27 => 1.0.31
sourceror 0.11.2 => 0.12.3 (minor)
ssl_verify_fun 1.1.6 => 1.1.7
surface 0.9.1 => 0.11.0 (minor)
tailwind 0.1.9 => 0.1.10
telemetry 1.1.0 => 1.2.1
telemetry_registry 0.3.0 => 0.3.1
tesla 1.5.0 => 1.7.0

Same bug with Elixir 1.14 & 1.15.

Which update do you think could be responsible for the problem? Has anyone encountered the same bug?

Thanks for your time.

Marked As Solved

GoulvenClech

GoulvenClech

Thanks a lot @ChristopheBelpaire , it was exactly the same problem but with Surface!

The solution :

      <Form
        for={@changeset}
        submit={:submit}
        multipart
        opts={
          "phx-target": @myself,
          class: "grid grid-cols-1 gap-5 sm:grid-cols-6"
        }
      >

I used the “submit” prop (not documented on Surface doc ?) instead of phx_submit, and I changed phx_target for "phx-target". Finally, I added target={@myself} on the Submit button.

Works like a charm!

Also Liked

ChristopheBelpaire

ChristopheBelpaire

I think I had the same problem when updating to live view 0.19
The name of the event in the form changed from phx_submit to phx-submit.
Your form in the template should be something like :
<.form
:let={f}
for={@changeset}
as={:product_model}
phx-change={:validate}
phx-submit={:save}
multipart={true}
%

Where Next?

Popular in Questions Top

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
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
jaysoifer
Is there a way to rollback a specific migration and only that one ("skipping" all the other ones)? Would mix ecto.rollback -v 2008090...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
pmjoe
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
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39247 209
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
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
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
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35953 110
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I'm a nov...
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
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

We're in Beta

About us Mission Statement