Rails4,如何使用文本数组循环模型列名

时间:2014-11-28 01:55:27

标签: ruby-on-rails ruby-on-rails-4

我循环所有工作日数据并在网络浏览器上打印

我的DateModel是

 monday_start_time: 09:00
           monday_end_time: 
        tuesday_start_time: 
          tuesday_end_time: 
      wednesday_start_time: 
        wednesday_end_time:
       thursday_start_time: 
         thursday_end_time: 
         friday_start_time:
           friday_end_time: 
       saturday_start_time:
         saturday_end_time:

我想循环只有周姓喜欢

day_data = DayModel.first
days = ["monday", "tuestday", "wednesday", "thursday", "friday"]
days.each do |d|
  puts  day_data."d+start_time"
end

是否可以使用文本数组循环模型列?

如果可能,如何在编辑器上输入?

0 个答案:

没有答案