Class: Golden::ActiveRecordForm
- Inherits:
-
ApplicationForm
- Object
- ApplicationForm
- Golden::ActiveRecordForm
- Defined in:
- lib/golden/objects/form/active_record_form.rb
Constant Summary
Constants included from BooleanAccessor
Instance Method Summary collapse
-
#initialize(params, accessors = {}) ⇒ ActiveRecordForm
constructor
A new instance of ActiveRecordForm.
- #save ⇒ Object
Methods inherited from ApplicationForm
Methods included from DateTimeAccessor
Methods included from ExtendedAttrAccessor
#attributes, #strip_attributes, #strip_attributes!
Constructor Details
#initialize(params, accessors = {}) ⇒ ActiveRecordForm
Returns a new instance of ActiveRecordForm.
5 6 7 8 |
# File 'lib/golden/objects/form/active_record_form.rb', line 5 def initialize(params, accessors = {}) assign_attributes(strip_attributes(params)) assign_attributes(strip_attributes(accessors || {})) end |
Instance Method Details
#save ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/golden/objects/form/active_record_form.rb', line 10 def save return false if invalid? ::ActiveRecord::Base.transaction do run_callbacks(:save) { persist! } end errors.empty? end |