Ruby on rails 4 如何根据rails中选择的日期[从和到]显示列?

Ruby on rails 4 如何根据rails中选择的日期[从和到]显示列?,ruby-on-rails-4,Ruby On Rails 4,|2016年1月| 2016年2月| 2016年3月| 2016年4月| 2016年5月| 2016年6月| 2016年7月| 2016年8月| 2016年9月| 2016年10月| 2016年11月| 2016年12月|| “从”和“到”过滤器是我们必须选择日期的过滤器。根据所选的值,我们必须动态选择位于所选日期筛选器之间的列 这些是不同的列。我必须根据rails中From和to datepicker中选择的日期显示列 例如:假设“From:=>Jan_2016”和“To=>June_2016

|2016年1月| 2016年2月| 2016年3月| 2016年4月| 2016年5月| 2016年6月| 2016年7月| 2016年8月| 2016年9月| 2016年10月| 2016年11月| 2016年12月||

“从”和“到”过滤器是我们必须选择日期的过滤器。根据所选的值,我们必须动态选择位于所选日期筛选器之间的列

这些是不同的列。我必须根据rails中From和to datepicker中选择的日期显示列

例如:假设“From:=>Jan_2016”和“To=>June_2016”,那么我们必须播放这两个日期之间的所有列[例如=>Jan_2016 | Feb_2016 | Mar_2016 | Apr|u 2016 | May|u 2016 | June| 2016 |]

谢谢。

这是您的解决方案

    current_date = from.to_date
    result = []
    while ( current_date <= to.to_date )
      result << current_date.strftime("%b_%Y") 
      current_date = current_date.next_month
    end
current_date=from.to_date
结果=[]

虽然(当前日期试试这个。这不是最好的解决方案,但可能有效

   start_date = params[:to]
   end_date = params[:from]
   columns = Model.column_names
   # For date filters
   start_date_index = columns.index(start_date)
   end_date_index = columns.index(end_date)
   result = columns[start_date_index..end_date_index]

你到底想做什么?你能详细解释一下吗?我已经更新了我的问题。谢谢你的回答。你的回答有助于找到解决方案。谢谢。