<% id = 0 [ [:article, :test, 1], [:article, :welcome, 2], [:page, :about, 1], [:page, :projects, 2] ].each do |commentable_type, commentable_name, commentable_id| [ [:author, :john_doe, 1], [:author, :jane_doe, 2], [:user, :anonymous, 1], [:user, :registered, 2] ].each do |commenter_type, commenter_name, commenter_id| %> <%= commentable_type %>_<%= commentable_name %>_<%= commenter_type %>_<%= commenter_name %>: id: <%= id += 1 %> commentable_id: <%= commentable_id %> commentable_type: <%= commentable_type.to_s.camelize %> commenter_id: <%= commenter_id %> commenter_type: <%= commenter_type.to_s.camelize %> <% end end %>