1

我想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
4

0 回答 0