Module: DaisybillApi::Ext::CRUD::Create::InstanceMethods
- Defined in:
- lib/daisybill_api/ext/crud/create.rb
Instance Method Summary collapse
- #create ⇒ Object
-
#save ⇒ Object
Creating or Updating a record.
Instance Method Details
#create ⇒ Object
100 101 102 |
# File 'lib/daisybill_api/ext/crud/create.rb', line 100 def create send_data :post, index_path end |
#save ⇒ Object
Creating or Updating a record
Creating a record
pt = DaisyBillApi::Models::Patient.new(
billing_provider_id: 14,
first_name: "Johnny",
last_name: "Smith",
ssn: "123456789",
gender: "Male"
)
pt.save # => true
Updating a record
pt = DaisybillApi::Models::Patient.find(12) # => <DaisybillApi::Models::Patient id: 12...>
pt.telephone # => "2138888888"
pt.telephone = "2137777777" # => "2137777777"
pt.telephone # => "2137777777"
pt.save # => true
Inspecting errors
pt = DaisybillApi::Models::Patient.new(billing_provider_id: 14, first_name: "Johnny")
pt.save # => false
pt.errors. # => ["Last name can't be blank"]
91 92 93 94 95 96 97 |
# File 'lib/daisybill_api/ext/crud/create.rb', line 91 def save return create if new_record? return update if respond_to? :update = "#save method is not supported for saved record" DaisybillApi.logger.error raise NotImplementedError.new end |