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 8368041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:17:50+00:00 2026-06-09T13:17:50+00:00

Okay so when I submit the form these are the parameters passed through my

  • 0

Okay so when I submit the form these are the parameters passed through my browser:

{"Search"=>"Job Letter and CD #",
"utf8"=>"✓",
"search"=>"g",
"commit"=>"Search"}

Basically what I need to do is in my model test the first parameter “Search”.
Ex:

if Search == "Job Letter and CD #"
..do stuff..
elsif Search == "something else"
..do different stuff..
else
..do something..

I have been pounding my head over this and cant figure it out. My ruby code is below i may cut out some “end”‘s and stuff like that to save room.

index.html.erb

<form class="well form-search right">
<%= select_tag "Search", options_for_select([ "Job Letter and CD #", "Date", "Cust",            "Job", "Date shipped", "Date billed", "Billed by" ], params[:search]) %>
<%= form_tag reports_path, :method => 'get' do %> 
<%= text_field_tag :search, params[:search], :class=> "form-search", :align => "right" %>
<%= submit_tag "Search", [ :JOBLETTER_CD_NUMBER, :DATE, :CUST, :JOB, :DATE_SHIPPED, :DATE_BILLED, :billed_by ] => nil, :class => "btn btn-success", :align => "right" %>

report.rb model

      def self.search(search)  
if Search == 'Job Letter and CD #'
  where('JOBLETTER_CD_NUMBER LIKE ?', "%#{search}%") 
elsif Search == 'Date'
  where('DATE ?', "%#{search}%")
else
  scoped  
end
end  
  • 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-09T13:17:51+00:00Added an answer on June 9, 2026 at 1:17 pm

    I guess you need to pass 2 parameters to your search function present in the model

    def self.search(what_to_search,search_string)
      if what_to_search == 'Job Letter and CD #'
         where('JOBLETTER_CD_NUMBER LIKE ?', "%#{search_string}%") 
      elsif what_to_search == 'Date'
         where('DATE ?', "%#{search_string}%")
      else
          scoped  
      end
    end
    

    And call search from your controller in this way

    Search.search(params[:Search],params[:search])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay so my code pretty much works... except if you click submit a second
Okay, next PHPExcel question. I have an HTML form that users fill out and
I'm having this problem with a form, whenever I submit a form in this
I have a form like this: <form id=form_main name=form_main action=/search/ target=iframe001 method=get onSubmit=reset_and_subm();> Enter
Okay please help, I've been frustrated with this issue. I need to either set
I have this code $(document).ready(function(){ // ... $('form').submit(function() { // ... $.ajax({ type: GET,
Is this the correct way to split out code to smaller functions? $(document).ready(function(){ $(form#create_form).submit(function()
Okay, so I have the form set to my PHP page. I also have
I am creating a form wizard that guides the user through each form element,
I'm using Twitter's Bootstrap modal functionality . When someone clicks submit on my form,

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.