Rails 5.2.3
在我的route.rb中,我有:
resources :devices
当我做耙子路线时,我得到:
devices GET /devices(.:format) devices#index
device GET /devices/:id(.:format). devices#show
在我的devices / index.html.slim中,我有:
td = link_to 'Show', device
当我为Device模型创建支架时(我使用的是simple_form gem和SLIM gem),Rails会自动生成什么?
当我进入“设备索引”视图时,一切在视觉上都可以正常工作。日志文件显示:
Processing by DevicesController#index as HTML
Rendering devices/index.html.slim within layouts/application
......
Completed 200 OK in 140ms (Views: 129.3ms | ActiveRecord: 7.2ms)
但是,当我单击Show链接时,对于其中一台设备,我收到以下错误消息:
Started GET "/devices/1566432871.922924" for ::1 at 2019-08-21 17:47:13 -0700
ActionController::RoutingError (No route matches [GET] "/devices/1566432871.922924"):
在索引视图中,我也尝试过:
td = link_to('Show', device_path(device), method: :get)
相同错误。有任何想法吗?这应该按原样进行。