Rails XML Builder - Code refactoring
Posted
by Vijay Dev
on Stack Overflow
See other posts from Stack Overflow
or by Vijay Dev
Published on 2009-12-02T15:51:14Z
Indexed on
2010/06/14
14:22 UTC
Read the original article
Hit count: 442
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
© Stack Overflow or respective owner