Module: ResourceControllerExtensions::XML::ClassMethods

Defined in:
lib/resource_controller_extensions/xml.rb

Instance Method Summary collapse

Instance Method Details

#init_default_actions_with_xml(klass) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/resource_controller_extensions/xml.rb', line 13

def init_default_actions_with_xml(klass)
  init_default_actions_without_xml(klass)
  klass.class_eval do
    index.wants.xml { render :xml => collection.to_xml, :status => :ok }
    show.wants.xml { render :xml => object}
    edit.wants.xml { render :xml => object}
    new_action.wants.xml { render :xml => object }

    create.wants.xml { render :xml => object, :status => :created, :location => object_url }
    create.failure.wants.xml { render :xml => object.errors, :status => :unprocessable_entity }
    destroy.wants.xml { head :ok }
    update.wants.xml { head :ok }
    update.failure.wants.xml { render :xml => object.errors, :status => :unprocessable_entity }
  end
end