ruby - rails 3 route 疑惑?
阿神
阿神 2017-04-21 10:55:57
0
1
538

在项目中使用:rake routes 得到如下:
db_spells_export_json GET
/db/spells/export_json(.:format)
db/spells#export_json
在helper方法中使用:
link_to "export-json",db_spells_export_json"
刷新页面时:
undefined local variable or method `db_spells_export_json' for #<#<Class:0x0000010585ff88>:0x0000010585ab00>
我理解是说路由我已经设置好了 调用方法:db_spells_export_json 的意思是说我进入:db/spells#export_json
是吗?为什么会出现 没有找到“`db_spells_export_json”方法错误 呢?

阿神
阿神

闭关修行中......

Antworte allen(1)
巴扎黑

我想可能是link_to写法的问题,试试下面的:

link_to "export-json", db_spells_export_json_url
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!