Sha256: 5850a155c2187b845e76184213063700ee7923b8e23cb6be9ffe98afb70915d2

Contents?: true

Size: 468 Bytes

Versions: 1

Compression:

Stored size: 468 Bytes

Contents

module Persisted
  module RecordCreator
    def persisted_record
      @persisted_record ||= super || create_record
    end

    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

    def create_record
      self.class.persisted_record_class.create attributes_for_creation
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
persisted-0.0.1 lib/persisted/record_creator.rb