Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
418 views
in Technique[技术] by (71.8m points)

ruby - Rails dot instead of slash in URL

In my routes.rb I have:

get "projects/:category_id" => "projects#index"

When I write projects_path(1) the generated URL is /projects.1 instead of /projects/1. Do you know why this is happening? Here is the output of rake routes:

 GET /projects/:category_id(.:format) projects#index
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

projects_path is the index, which only takes one argument: the format. You want project_path(1)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...