- <% 1.upto(50) do |number| %>
- child_post_<%= number %>:
- id: <%= number + 3 %>
- title: This is auto-generated reply number <%= number %>
- body: We're on number <%= number %>
- created_at: 2006-01-30 08:03:56
- updated_at: 2006-01-30 08:03:56
- <%# Randomly choose a parent from a post we've already generated -%>
- parent_id: <%= rand(number - 1) + 1 %>
- user_id: <%= rand(5) + 1 %>
- <% end %>
我们还可以定义一些helper方法:
- <%
- def today
- Time.now.to_s(:db)
- end
- def next_week
- 1.week.from_now.to_s(:db)
- end
- def last_week
- 1.week.ago.to_s(:db)
- end
- post_from_last_week:
- id: 60
- title: pizza
- body: Last night I had pizza. I readlly liked that story from AWDWR.
- created_at: <%= last_week %>
- updated_at: <%= last_week %>
- user_id: 1
- post_created_in_future_should_not_display:
- id: 61
- title: Prognostication
- body: I predict that this post will show up next week.
- created_at: <%= next_week %>
- updated_at: <%= next_week %>
- updated_post_displays_based_on_updated_time:
- id: 62
- title: This should show up as posted today.
- body: blah blah blah
- created_at: <%= last_week %>
- updated_at: <%= today %>
- user_id: 2
安徽新华电脑学校专业职业规划师为你提供更多帮助【在线咨询】