Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8528753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:52:23+00:00 2026-06-11T08:52:23+00:00

I have a setup attempting to automate submission to a backend. There are 3

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:52:25+00:00Added an answer on June 11, 2026 at 8:52 am

    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.

    <%= form_for(@xsearch) do |f| %>
      <% if @xsearch.errors.any? %>
        <div id="error_explanation">
          <h2><%= pluralize(@xsearch.errors.count, "error") %> prohibited this xsearch from being saved:</h2>
    
          <ul>
          <% @xsearch.errors.full_messages.each do |msg| %>
            <li><%= msg %></li>
          <% end %>
          </ul>
        </div>
      <% end %>
        <div class="field">
          <h2>Pick A Database To Search</h2>
          <%= collection_select(:db, :id, @all_entries, :id, :name) %>
          <h2>Pick A Parameter File To Use</h2>
          <%= collection_select(:para, :id, @all_parameters, :id, :name) %>
          <h2>Pick a File or Folder To Search</h2>
          <%= collection_select(:sfile, :id, @all_spectrafiles, :id, :name) %>
        </div>
    
      <div class="actions">
        <%= f.submit %>
      </div>
    <% end %>
    

    And the relevant bit in the controller’s create: method

    def create
      @database = Xentry.find(params[:db][:id])
      @paramfile = Parameter.find(params[:para][:id])
      @spectrafile = Spectrafile.find(params[:sfile][:id])
      @recurse = params[:recurse]
      @email = params[:emailtag]
      if @email.empty?
        @email = "None"
      end
      if (@recurse == 'Yes')
        @recurse = 1
      else
        @recurse = 0
      end
      @recurse = 0#disabled until kill methods are implemented
      @hostname = hostname
      @username = username
      Net::SSH.start(@hostname, @username) do |session|
        session.exec('source .bashrc')
        session.exec('sh rscript.sh %s %s %s %s %d' % [@database['name'], @spectrafile['name'], @paramfile['name'], @email, @recurse])
        @xsearch = Xsearch.new(:database => @database['name'], :parameters => @paramfile['name'], :spectra => @spectrafile['name'])
        respond_to do |format|
          if @xsearch.save
            format.html { redirect_to @xsearch, notice: 'Search was successfully created.' }
            format.json { render json: @xsearch, status: :created, location: @xsearch }
          else
            format.html { render action: "new" }
            format.json { render json: @xsearch.errors, status: :unprocessable_entity }
          end
        end
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have setup ability for a user to specify some settings using the in-built
I have a data set that i am attempting to select the first record
I'm attempting to setup a MenuItem that will have a submenu of page numbers
I'm attempting to setup a .csproj file to have a conditional item group which
I setup my website to require unique email addresses (no two users can have
I have been attempting to set up magento on a shared hosting server that
I have a Setup/Deployment project for my C# and attempting to delete a file
I am attempting to get django working using pypy. I have everything setup and
I have setup airbrake in my app but it doesn't seem to log any
I have setup an app project and a static project in a workspace in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.