I have a setup attempting to automate submission to a backend. There are 3 different dropdown boxes with user-selectable parameters. I set up my website like this (all ‘scaffolds’):
class Xsearch < ActiveRecord::Base
has_many :xentry
has_many :spectrafile
has_many :parameter
end
Each entry/file/parameter has the belongs_to :xsearch in their model.
The index.html.erb of the xsearch has the following:
<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" %>
I’ve tried using submit_tag as well. I have no idea how to trigger a method in my controller (if it should be in the controller? Since it’s from the browser I assumed to put it here) that has the selected values from each collection_select.
So in short: How can I take the selected values for each collection_select and pass them to a function? Where should that function be placed (in the controller or in the .html.erb file)?
Thanks, this has been driving me crazy.
I ended up solving the issue by moving to a form_new method. Here’s my code for anyone else who is searching. The purpose of this script was to allow other users to submit a search to a cluster through an authorized user.
And the relevant bit in the controller’s create: method