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

  • Home
  • SEARCH
  • 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 8320537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:40:56+00:00 2026-06-08T22:40:56+00:00

Quick question. I am trying to set up a page that searches a database

  • 0

Quick question. I am trying to set up a page that searches a database using a start date, end date and keywords. If i was to search 19-07-2012, the path would look like

search?utf8=%E2%9C%93&project%5Bstart_date%5D=19-07-2012&project%5Bend_date%5D=&%5Bstatus%5D=&keywords=

and all results would show. However when I search keywords, the search works. I can’t see where I’m going wrong.

<h1>Search</h1>




<%= form_tag search_path, method: :get do %>
Start Date :

<%#= text_field_tag :start_date, params[:start_date] %></br>

<div class="field">

<%= datepicker_input "project","start_date" %></br>
</div>

End Date :

<%#= text_field_tag :end_date, params[:end_date] %></br>
<%= datepicker_input "project","end_date" %></br>


Status :

<%= select(@projects, :status, Project.all.map {|p| [p.status]}.uniq, :prompt => "-Any-", :selected => params[:status]) %></br>

Keywords :

<%= text_field_tag :keywords, params[:keywords] %></br>

<%= submit_tag "Search", name: nil %>

<% end %>

Contoller:

def search



@project_search = Project.search(params[:start_date], params[:end_date], params[:keywords]).order(sort_column + ' ' + sort_direction).paginated_for_index(per_page, page)

   @project = Project.new(params[:project])

respond_to do |format|
      format.html # search.html.erb
      format.json { render :json => @project }
    end

end

EDIT:

When I search with the character “q” as a keyword, and the start date as 25-07-2012, the sql looks like this

Parameters: {"utf8"=>"✓", "project"=>{"start_date"=>"25-07-2012", "end_date"=>""}, "status"=>"", "keywords"=>"q"}
  Project Load (0.4ms)  SELECT "projects".* FROM "projects" 
   (0.2ms)  SELECT COUNT(*) FROM "projects" WHERE (client LIKE '%%' AND industry LIKE '%%' AND role LIKE '%%' AND tech LIKE '%%' AND business_div LIKE '%%' AND project_owner LIKE '%%' AND exception_pm LIKE '%%' AND status LIKE '%%' AND start_date LIKE '%%' AND end_date LIKE '%%' AND keywords LIKE '%q%')

This only seems to search on the keyword “q”. When I remove the keyword and leave the date in, the sql looks like:

Parameters: {"utf8"=>"✓", "project"=>{"start_date"=>"25-07-2012", "end_date"=>""}, "status"=>"", "keywords"=>""}
  Project Load (0.3ms)  SELECT "projects".* FROM "projects" 

Thanks in advance for any help given!

  • 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-08T22:40:56+00:00Added an answer on June 8, 2026 at 10:40 pm

    I have fixed my own problem. I changed my application.js file and my search view.

    Application.js:

    jQuery(function(){
        jQuery('#start_date').val("");
        jQuery('#start_date').datepicker({dateFormat: 'dd-mm-yy'});
    });
    
    jQuery(function(){
        jQuery('#end_date').val("");
        jQuery('#end_date').datepicker({dateFormat: 'dd-mm-yy'});
    });
    

    Search view:

    Start Date :
    <%= text_field_tag("start_date") %></br>
    
    End Date :
    <%= text_field_tag("end_date") %></br>
    

    My application now searches with a start and an end date.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

quick question about using ORMLite. I am trying to make sure that my implementation
Here's what I hope is a quick question... I am trying to set a
I am trying to start learning OO JS and have one quick question (i
Quick question. I'm trying yo access one of the fields of a model using
Quick question. If i am trying to clear multiple divs with the same class
Quick question about JavaScript event objects - how does JavaScript know when I'm trying
Quick question, I'm trying to pass a value to a variable and then run
Quick question hopefully someone can help out here. I'm trying to copy and paste
just a quick question, was trying different ways to accomplish this, but ended with
As a quick overview: I'm trying to make a game of pool using Box2D

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.