I have a grant_requests
controller and I want all all of the actions to show up as "sponsored_licences" in the url.
我有一个grant_requests控制器,我希望所有的所有操作都显示为url中的“spons_licences”。
My routes file has the following:
我的路线文件包含以下内容:
resources :sponsored_licences, as: :grant_requests, controller: :grant_requests
resources:spons_licences,as :: grant_requests,controller :: grant_requests
Going to new_grant_request_path
works as expected; it routes to the sponsored_licenses/new
url when the form is valid it posts correctly to the database.
转到new_grant_request_path按预期工作;当表单有效时,它会路由到spons_licenses / new url,它会正确地发布到数据库。
However, when there are form validation errors and I render new_grant_request_path
in the controller I get the Missing template
error.
但是,当存在表单验证错误并且我在控制器中呈现new_grant_request_path时,我得到Missing模板错误。
Redirecting will not work (I want to save the form data, etc.) and I am at a loss on how to correctly render the form. Is there something else I have to add to my routes file?
重定向不起作用(我想保存表单数据等),我对如何正确呈现表单感到茫然。还有什么我必须添加到我的路线文件?
1 个解决方案
#1
1
Try render :new
if you're in the GrantRequests controller, otherwise, render "grant_requests/new"
尝试渲染:如果你在GrantRequests控制器中则为new,否则渲染“grant_requests / new”
#1
1
Try render :new
if you're in the GrantRequests controller, otherwise, render "grant_requests/new"
尝试渲染:如果你在GrantRequests控制器中则为new,否则渲染“grant_requests / new”