Closed bmalum closed 8 years ago
I believe we are missing the step where you add the routes to your web/router.ex
. For example, when is "/api/posts/1/comments/1/test" added?
Oh my fault - after Creating the second resource web/router
looks like this:
defmodule HelloPhoenix.Router do
use HelloPhoenix.Web, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/", HelloPhoenix do
pipe_through :browser # Use the default browser stack
get "/", PageController, :index
end
# Other scopes may use custom stacks.
scope "/api", HelloPhoenix do
pipe_through :api
resources "posts", PostController do
resources "comments", CommentController do
get "test", CommentController, :test
end
end
end
end
Can you verify that the above router is the one that triggered this? It should have raised an error with get "test"
since it missing a forward slash, and the output in the mix task is :comment
action, not :test
I can't recreate this, but I did confirm that we have a regression that allows router paths without a forward slash, we should be raising. Can you verify your elixir version?
I'm pretty sure, the first try was with comment
in the route, the second one with test
. I will try on another System at the evening again.
My Elixir Version is: Elixir 1.1.1
@chrismccord I thought at some point we decided to drop the restriction? I can't remember anymore.
@chrismccord @josevalim yes you removed the restriction it didn't happen to me but I have to restart the server every time I add a new route.
@hectorip let's rule out your editor using a syntax checker plugin that recompiles the project behind the scenes. I'm willing to be that is what is happening, causing the running server to not pick up any changes because it sees no files that need recompiled/reloaded
Hi to all - I just had to restart my Server on Elixir 1.1.1 on a completely different setup and machine - I immediately committed the changes and pasted the phoenix.server
output in the commit message.
You can find the commit here: bmalum/Constructeev_Elixir@21166a030b40b81c42161af0bdf2a335a987419e
@bmalum so is it working as expected now?
@bmalum, are you using an editor plugin that does syntax checking? These have been known to cause reloading issues since they recompile the project behind the scenes.
@chrismccord - good hint. I'm using SublimeText with several Plugins (Elixir, Angular …) - I tried again with @Gazler today using a plain VI - everything worked fine. I thought Elixir Package from Sublime does not compile in background. Very Strange :/
I'm closing this for now. If you are able to recreate, please reopen. Thanks!
This happened to me, in VS Code with the main Elixir package installed, while I was trying the first tutorial from phoenixproject.org.
The problem, router.ex
wasn't loading without a server restart.
I switched to emacs and it all worked as expected.
In bash, the error looked like this:
[debug] ** (Phoenix.Router.NoRouteError) no route found for GET /hello/John (HelloWeb.Router)
(hello) lib/hello_web/router.ex:1: HelloWeb.Router.__match_route__/4
(hello) lib/phoenix/router.ex:303: HelloWeb.Router.call/2
(hello) lib/hello_web/endpoint.ex:1: HelloWeb.Endpoint.plug_builder_call/2
(hello) lib/plug/debugger.ex:99: HelloWeb.Endpoint."call (overridable 3)"/2
(hello) lib/hello_web/endpoint.ex:1: HelloWeb.Endpoint.call/2
(plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
(cowboy) /Users/[...]/phoenix/hello/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
I noticed after adding a custom action to a nested resource that Phoenix claims the route can not be found. I have discussed the problem with @Gazler in the Elixir IRC channel and he said the server restart should be not necessary - I tried to reproduce the Issue and will describe you all the steps I've done. Thanks to @Gazler for taking time to help me.
Creating a simple hello_phoenix
Creating a Post resource like in the Guide
Creating the second resource.
Migrating the DB
To avoid compiler error i have removed the Comment-Templates and
|> redirect(to: post_comment_path(conn, :index))
Lines - this should not cause the bugWe can see that
/api/posts/:post_id/comments/:comment_id/test
does exist inmix phoenix.routes
output ... Notice that the server has been started before the route has been added andmix phoenix.routes
was called.here is the response:
response.txt