When writing with ** link_to ** so that when you press the post button during application development, you will be taken to the post page
<%= link_to "Post", 'new_photo_path'%>
At first, I wrote it like this. Then always![Screenshot 2020-10-15 3.30.59.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/694122/40c3de74-5e3e-107a -7bcb-78f8143f741f.png) I got this red error. ..
** routes.rb ** is not well described Spelled wrong
routes.rb
resources :photos, except: :index
root to: 'photos#index'
There is nothing strange other than excluding index in resources
rails routes
There is no problem even if you check with ...
I didn't misspell it ...
** Described Controller # Action instead of Prefix ** new_photo GET /photos/new(.:format)
index.html.erb
<%= link_to "Post", '/photos/new'%>
Solved with ...
The cause was found in the comment from @scivola
Thank you @scivola.
Prefix seems to be a ** string ** if you enclose it in ''
...
So in my case it seems to be recognized as a character string
Recommended Posts