I’m trying to create a simple blog in phoenix 1.3 , I’ve done this with 1.2 before. After generating the post resource with the phx.gen.html command and adding coherence I keep getting this weird interaction. In order to keep posts read-only without a session I added the following to the public resource route:
How are you executing new post creation? Because you have defined only two actions for post.[quote=“Zesky665, post:1, topic:10041”]
only: [:index, :show]
[/quote]
Need more details and I think we will find the problem.
The rest of the actions are in the :protected scope set up with coherence, here is what mine looks like.
scope "/", BlogAppWeb do
pipe_through :browser
get "/", PageController, :index
resources "/posts", PostController, only: [:index, :show]
# Add public routes below
end
scope "/", BlogAppWeb do
pipe_through :protected
resources "/posts", PostController
# Add protected routes below
end
The idea is that you can use the :index and :show actions anytime but you need to be logged in to use any of the others like :new. This works for other actions like :edit but not for :new.
I don’t think that routing is going to work, won’t the first scope match all requests and none will go to the authed scope? Or will Phoenix try other scopes if there is no match for a route inside a scope?
The way it’s supposed to work at least is that, if you go into one of the routes that is not in the public route, it will give you a login screen. This works with every other action/route but it throws this error when using the :new action.