Ces*_*sar 2 ruby-on-rails ruby-on-rails-4
我想创建一个指向路由的链接
我的routes.db具有以下规则
match '/tablero', to: 'tablero#index',via: 'get' , as: 'tablero_main'
Run Code Online (Sandbox Code Playgroud)
我可以看到使用rake路线的路线
tablero_main GET /tablero(.:format) tablero#index
Run Code Online (Sandbox Code Playgroud)
但是当我按如下方式使用link_to时,我得到"未定义的局部变量或方法`tablero_main'"错误.
<%= link_to "Tablero",tablero_main %>
Run Code Online (Sandbox Code Playgroud)
还有什么我想念的吗?
您需要附加path到方法名称,如下所示:
<%= link_to "Tablero", tablero_main_path %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
73 次 |
| 最近记录: |