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

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

Frage

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

War es hilfreich?

Lösung

url_for([:new, :project])

Will do the trick.

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top