How would i get data from date?

I am using Ruby 1.9.3 and Rails 3.2.16.

What i want to do is When i select date in **search** text field, i would get date corresponding to that date.

Code in view:

<%= form_tag quantities_path, :method => 'get' do %>   <p>     <%= text_field_tag :search, params[:search], :class => "datepicker" %>     <%= submit_tag "Search", :name => nil %>   </p> <% end %>

Code in model:

def self.search(search)     if search       find(:all, :conditions => ['expense_on LIKE ?', "%#{search}%"])      else        find(:all)       end     end

schema.rb contain:

ActiveRecord::Schema.define(:version => 20140720063348) do

  create_table "quantities", :force => true do |t|     t.string "title"     t.decimal "price", :precision => 8, :scale => 2     t.datetime "created_at", :null => false     t.datetime "updated_at", :null => false     t.string "day"     t.string "month"     t.string "year"     t.date "expense_on"   end end

code in controller:

def index     @quantities = Quantity.search(params[:search]) end

By using above code, when i select date in search column, i can not able get data. How could i get it?

Kind regards.

First, why are you using like for a date search???

To debug this:

- puts the search argument in the search method to make sure it's what you think it should be (and that search is actually called)

- look in the log at the SQL the rails is using, take that SQL and fiddle with it at the command line until you have a version that works, and figure out what to do to get RoR to generate similar SQL

And in the future, when you post questions, don't withhold information. Tell us what your attempt actually does. Yes, many people could figure out from what you've posted what's wrong and how to fix it, but it's easier if we know whether you're getting an error (and what the error is), or whether it's running but not returning any data, or returning the wrong data.