私はレールのルーティングを理解しようとしています。私はレールガイドを読みましたが、私はまだ混乱しています。私は唯一のindex, new, edit and show
アクションは左のパス名を持って上から見ることができるように作成、削除、更新アクションのためのRailsルート
posts GET /posts(.:format) posts#index
POST /posts(.:format) posts#create
new_post GET /posts/new(.:format) posts#new
edit_post GET /posts/:id/edit(.:format) posts#edit
post GET /posts/:id(.:format) posts#show
PATCH /posts/:id(.:format) posts#update
PUT /posts/:id(.:format) posts#update
DELETE /posts/:id(.:format) posts#destroy
:たとえば、私は以下のようにすべてのレールのCRUDアクションとposts_controllerを持っています。たとえば、index
アクションのパス名はposts
で、URLはposts_path
となります。そして、私はリンクタグで以下のように使用できます。
<a href="<%= posts_path %>">here</a>
ただし、作成、更新、破棄のアクションのパス名はありません。では、下のリンクでこの場合の作成アクションのURLを取得するにはどうすればよいですか?
<a href="<%= ..... link to create action of post controller %>">here</a>