私はRoRを初めて使い、現在いくつかのテスト作業を達成中です。 私はupdate_date
からselect_tag
を私のフォームから選んで、Showボタンを押してください。その後、その選択したupdated_date
に従って同じページ(index.htmlの 'update-container' div)対応する情報をdbから見たいと思っています。私はそれだけでなく、 'stackoverflowed'それをGoogleにしようとしていたが、私はちょうどもっとつまってしまったたびに&もっと。選択フィールドレールからオプションを選択した後に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''メソッドは、この場合、' ''/dashboards''と ''/dashboards /:id'''ルートを単に拒否します。あなたは/ showルートを持っていません(もしレーキルートの出力を確認するなら、利用可能なルートを見ることができます)。 –
@stockholm_syndrome フォームタグで 'show'を' dashboard_path'(引用符なし)に変更しようとします。 – cnnr
@cnnr、ありがとうございます。しかし、このソリューションを使用しても、私はまだ "No route matches ..."を受け取ります。 –