0
我有以下方法獲取2日期間所有的約會:方法在第二次調用時拋出一個參數錯誤?
def self.search_app(start_date, end_date)
if start_date
start_date = Date.new(start_date['(1i)'].to_i, start_date['(2i)'].to_i, start_date['(3i)'].to_i)
end_date = Date.new(end_date['(1i)'].to_i, end_date['(2i)'].to_i, end_date['(3i)'].to_i)
find(:all, :conditions => {:date_of_appointment => (start_date)..(end_date) })
else
find(:all)
end
end
,並在視圖:
<div id="search">
<% form_tag doctor_appointments_path(@person), :method => "get" do %>
<span> From </span>
<%= date_select :start_date, :start_date %>
<span> Until </span>
<%= date_select :end_date, :end_date %>
<%= submit_tag "Search", :name => nil %>
<% end %>
</div>
控制器代碼:
def index
@appointments = person.appointments.search_app(params[:start_date], params[:end_date])
end
方法偉大工程第一它的時間,但如果我再次嘗試搜索我得到一個參數錯誤:
Invalid date
{"start_date"=>{"start_date(1i)"=>"2010",
"start_date(2i)"=>"8",
"start_date(3i)"=>"5"},
"doctor_id"=>"1",
"end_date"=>{"end_date(3i)"=>"17",
"end_date(1i)"=>"2010",
"end_date(2i)"=>"8"}}
不知何故,它通過醫生Id與Date.new方法?
任何想法如何我可以解決這個問題?
感謝
確定它停止在一起工作?爲什麼醫生的身份證號碼與日期的值相呼應? – 2010-08-17 21:45:46