I have written the following code in my Rails app to generate XML. I am using Aptana IDE to do Rails development and the IDE shows a warning that the code structure is identical in both the blocks. What changes can be done to the code to remove the duplicity in structure? Is there any other way to write the same?
xml.roles do
@rolesList.each do |r|
xml.role(:id => r["role_id"], :name => r["role_name"])
end
end
xml.levels do
@levelsList.each do |lvl|
xml.level(:id => lvl["level_id"], :name => lvl["level_name"])
end
end