lib/amfetamine/query_methods.rb in amfetamine-0.1.5 vs lib/amfetamine/query_methods.rb in amfetamine-0.2.0
- old
+ new
@@ -95,15 +95,15 @@
end
run_callbacks(:save) do
response = if self.new?
path = self.belongs_to_relationship? ? belongs_to_relationships.first.rest_path : rest_path
- self.class.handle_request(:post, path, {:body => self.to_json })
+ self.class.handle_request(:post, path, {:body => {class_name.to_sym => self.to_hash}})
else
# Needs cleaning up, also needs to work with multiple belongs_to relationships (optional, I guess)
path = self.belongs_to_relationship? ? belongs_to_relationships.first.singular_path : singular_path
- self.class.handle_request(:put, path, {:body => self.to_json})
+ self.class.handle_request(:put, path, {:body => {class_name.to_sym => self.to_hash}})
end
if handle_response(response)
begin
update_attributes_from_response(response[:body])
@@ -167,10 +167,10 @@
def to_cacheable
{
:status => :success,
:body => {
- self.class.name.downcase.to_sym => self.attributes
+ class_name.to_sym => self.attributes
}
}
end
private