バックエンドへの送信を自動化しようとするセットアップがあります。ユーザーが選択可能なパラメータを持つ 3 つの異なるドロップダウン ボックスがあります。私は自分のウェブサイトを次のように設定しました(すべて「足場」):
class Xsearch < ActiveRecord::Base
has_many :xentry
has_many :spectrafile
has_many :parameter
end
各エントリ/ファイル/パラメータには、モデル内に属している :xsearch があります。
xsearch の index.html.erb には次のものがあります。
<h1>Spectra Submitter</h1>
<h2>Select a database to search</h2>
<%= collection_select("xpost", :id, Xentry.all(), :title, :name ) %>
<h2>Select a parameter file to use</h2>
<%= collection_select(:ppost, :id, Parameter.all(), :name, :name ) %>
<h2>Select a Spectra file (or folder) to search</h2>
<%= collection_select(:spost, :id, Spectrafile.all(), :name, :name ) %>
<%= link_to "Search", :controller => "xsearches", :action => "search" %>
submit_tag も使用してみました。各collection_selectから選択された値を持つコントローラーでメソッドをトリガーする方法がわかりません(コントローラーにある必要がある場合は、ブラウザーからのものなので、ここに置くと想定しました)。
要するに: collection_select ごとに選択した値を取得して関数に渡すにはどうすればよいですか? その関数はどこに配置する必要がありますか (コントローラーまたは .html.erb ファイル内)?
ありがとう、これは私を夢中にさせています。