我是RoR的新手,目前正在完成一些测试任务。 我需要的是从我的形式,命中显示按钮的select_tag
选择update_date
之后,我想看看在同一页面上(在“更新容器”的index.html格)从相对应根据所选updated_date
分贝信息。我试图谷歌它以及'stackoverflowed'它,但每次我刚刚陷入更多&更多。从选择栏选择选项后更新index.html db值
我index.html.slim:
.container
.child-container
.show-date
= form_tag('/show',
method: :get,
remote: true,
enforce_utf8: false,
:'data-update-target' => 'update-container',
class: 'select_date')
do
= collection_select(:id, :id, Dashboard.all, :id, :update_date)
= submit_tag 'Show', name: nil
#update-container
我的routes.rb:
Rails.application.routes.draw do
resources :dashboards, only: [:index, :show]
root to: 'dashboards#index'
end
我dashboards_controller.rb:
class DashboardsController < ApplicationController
def index
@dashboards = Dashboard.all
end
def show
@dashboard = Dashboard.find(params[:id])
end
end
从这一点i`ve了“ ActionController :: RoutingError(没有路由匹配[GET]“/ show”):“。
我将非常感谢任何帮助。提前致谢。
的'''resources'''方法只是ganerates的'''/ dashboards'''和'''/仪表板/:在这种情况下id'''路由。你没有/ show route(如果你检查rake路由输出,你可以看到你的可用路由)。 –
@stockholm_syndrome 试着在你的表单标签改变'show'到'dashboard_path'(不带引号) – cnnr
@cnnr,感谢对此事发表评论。然而,使用这种解决方案,我仍然收到“没有路线匹配......” –