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]?

Était-ce utile?

La solution

url_for([:new, :project])

Will do the trick.

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top