【问题标题】:Ruby on Rails: How to include YAML content in a fixture?Ruby on Rails:如何在夹具中包含 YAML 内容?
【发布时间】:2020-09-07 11:26:31
【问题描述】:

我正在使用 IceCube gem 来构建会议重复,我想在 meeting.yml 固定装置中包含重复计划。

当我在 meeting.yml 夹具的重复属性中包含以下 YAML 内容时,其他夹具根本不会加载。

---
:start_time: 2020-05-21 12:00:00.000000000 -06:00
:end_time: 2020-05-21 12:15:00.000000000 -06:00
:rrules:
- :validations:
    :day:
    - 1
  :rule_type: IceCube::WeeklyRule
  :interval: 1
  :week_start: 0
- :validations:
    :day:
    - 2
  :rule_type: IceCube::WeeklyRule
  :interval: 1
  :week_start: 0
:rtimes: []
:extimes: []

对如何使用这些数据填充我的灯具有什么想法吗?

【问题讨论】:

    标签: ruby-on-rails yaml


    【解决方案1】:

    literal style did the trick 中的块样式指示器。

    meeting:
      start_date: <%= Time.current + 5.days %>
      recurrence: |+
        ---
        :start_time: 2020-05-21 12:00:00.000000000 -06:00
        :end_time: 2020-05-21 12:15:00.000000000 -06:00
        :rrules:
        - :validations:
            :day:
            - 1
          :rule_type: IceCube::WeeklyRule
          :interval: 1
          :week_start: 0
        - :validations:
            :day:
            - 2
          :rule_type: IceCube::WeeklyRule
          :interval: 1
          :week_start: 0
        :rtimes: []
        :extimes: []
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-06-14
      • 1970-01-01
      • 1970-01-01
      • 2014-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多