Module: ActiveResource::Validations

Defined in:
lib/patches/ar2/validations.rb

Instance Method Summary collapse

Instance Method Details

#save_with_validationObject

Validate a resource and save (POST) it to the remote web service.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/patches/ar2/validations.rb', line 5

def save_with_validation
  save_without_validation
  true
rescue ResourceInvalid => error
  case error.response['Content-Type']
  when /xml/ #PATCH
    errors.from_xml(error.response.body)
  when /json/ #PATCH
    errors.from_json(error.response.body)
  end
  false
end