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 data corresponding to that date.
Code in view:
<%= form_tag quantities_path, :method => ‘get’ do %>
<%= text_field_tag :search, params[:search], :class => "datepicker"%> <%= submit_tag "Search", :name => nil %>
<% 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.