Module: Persisted::RecordCreator
- Included in:
- Persisted
- Defined in:
- lib/persisted/record_creator.rb
Instance Method Summary collapse
Instance Method Details
#attributes_for_creation ⇒ Object
7 8 9 10 11 |
# File 'lib/persisted/record_creator.rb', line 7 def attributes_for_creation attrs = self.class.persisted_record_class.accessible_attributes - [''] # No idea where there is a blank string in there... attrs.each_with_object({}) { |k, a| a[k] = @params[k] } end |
#create_record ⇒ Object
13 14 15 |
# File 'lib/persisted/record_creator.rb', line 13 def create_record self.class.persisted_record_class.create attributes_for_creation end |
#persisted_record ⇒ Object
3 4 5 |
# File 'lib/persisted/record_creator.rb', line 3 def persisted_record @persisted_record ||= super || create_record end |