我正在为大学项目创建一个rails应用程序,我遇到了问题
未定义的局部变量或方法`project_materials_new'用于#
提取的来源(第18行):
if @project.save
redirect_to project_materials_new
#redirect_to @project
else
render 'new'
应用程序跟踪|框架跟踪|完整追踪 app / controllers / projects_controller.rb:18:在'create'
我想重定向到另一个控制器路由......这是我的(提取)路由表...
Prefix Verb URI Pattern Controller#Action
project_materials_new GET /project_materials/new(.:format) project_materials#new
static_home GET /static/home(.:format) static#home
static_grid GET /static/grid(.:format) static#grid
static_project GET /static/project(.:format)
正如您所看到的,我已经定义了project_materials_new路径....为什么我无法重定向到它?
答案 0 :(得分:3)
project_materials_new
只是一个前缀,使用project_materials_new_path或project_materials_new_url而不是它。
请参阅Rails文档了解详细信息:http://api.rubyonrails.org/classes/ActionDispatch/Routing.html