我希望看到我的room_requests
期限包含在我的日期范围内。这就是我所做的:
此视图的控制器:
def not_confirmed_slots
if params[:search]
@slots = RoomRequest.find(:all, :conditions => ['date >= ? and date =< ?', params[:start_date].strftime("%Y-%m-%d"), params[:end_date].strftime("%Y-%m-%d")])
if @projects.size.zero?
flash[:notice] = "No result found"
@slots = RoomRequest.find(:all)
end
else
@slots = RoomRequest.all
end
end
和我的表单来自视图:
%h1= t('headers.reports.notConfirmedSlots')
= form_tag not_confirmed_slots_reports_path, method: 'get' do
%p
= text_field_tag :start_date, nil, :class => "datepicker", :placeholder => t('placeholders.reports.startDate')
%p
= text_field_tag :end_date, nil, :class=>"datepicker", :placeholder => t('placeholders.reports.endDate')
.clear
.action_bar
= submit_tag t('buttons.reports.generate'), {class: "button blue"}
但是每次我提交带有日期的表单时,它都会列出db中的所有room_requests - 任何提示?
哦,这是部分的(它在同一个视图中是搜索表单):
%table
- @slots.each do |s|
%tr
%td
= s.bookers_name
%td
= s.request_type