Why does url_for [:new, Project] translate to new_projects_url (plural), not into new_project_url (singular)?

StackOverflow https://stackoverflow.com/questions/14873482

Question

$ url_for [Project]
=> projects_url
$ url_for [:new, Project]
=> new_projects_url
$ url_for [:new, Project, :test]
=> new_project_test_url
$ url_for [:new, Project, nil]
=> new_projects_url

I find url_for [:new, Project, :test] especially interesting: here project is singular!

Anyone has an idea how to generate a new_project_url (or path) from an array like [:new, Project]?

Was it helpful?

Solution

url_for([:new, :project])

Will do the trick.

OTHER TIPS

When using [:new, Project], :new is a namespace.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top