##
# return all the preferences as an XML document
def index
- doc = OSM::API.new.get_xml_doc
+ @user_preferences = current_user.preferences
- prefs = current_user.preferences
-
- el1 = XML::Node.new "preferences"
-
- prefs.each do |pref|
- el1 << pref.to_xml_node
- end
-
- doc.root << el1
- render :xml => doc.to_s
+ render :formats => [:xml]
end
##
validates :user, :presence => true, :associated => true
validates :k, :v, :length => 1..255, :characters => true
-
- # Turn this Node in to an XML Node without the <osm> wrapper.
- def to_xml_node
- el1 = XML::Node.new "preference"
- el1["k"] = k
- el1["v"] = v
-
- el1
- end
end
--- /dev/null
+attrs = {
+ "k" => user_preference.k,
+ "v" => user_preference.v
+}
+
+xml.preference(attrs)
--- /dev/null
+xml.instruct!
+
+xml.osm(OSM::API.new.xml_root_attributes) do |osm|
+ osm.preferences do |preferences|
+ preferences << (render(@user_preferences) || "")
+ end
+end