The story that link_to is deep (cause unknown)

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. ..

Assumption

** routes.rb ** is not well described Spelled wrong

I came to check routes.rb

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 ...

スクリーンショット 2020-10-15 3.35.14.png

I didn't misspell it ...

What went

** Described Controller # Action instead of Prefix ** new_photo GET /photos/new(.:format)

index.html.erb


<%= link_to "Post", '/photos/new'%>

Solved with ...

add to

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

The story that link_to is deep (cause unknown)
The story that .java is also built in Unity 2018
[Swift] The story that switch is often used for enum judgment
A story that suffered from a space that does not disappear even if trimmed with Java The cause is BOM
The story that docker had a hard time
A story about making a Builder that inherits the Builder
Java Error Handling Basics-The story that catch is only picked up in the foreground
A small story that is sometimes useful in Maven
PATH does not pass ... The cause is the character code
The story that the forced update could not be implemented
[Docker] Is it good enough to call it a multi-stage build? → The story that became so good