Sha256: 5fbc79016d45fd3dc7de90f004e91ecd1f3fd89a15ad0edaa806483b7bf78143
Contents?: true
Size: 675 Bytes
Versions: 11
Compression:
Stored size: 675 Bytes
Contents
# frozen_string_literal: true module OverrideSongAttributesTheRails4Way def attributes if name super.merge(name: name) else super end end def changed_attributes if name super.merge(name: name) else super end end end class Song < ActiveRecord::Base has_paper_trail # Uses an integer of seconds to hold the length of the song def length=(minutes) write_attribute(:length, minutes.to_i * 60) end def length read_attribute(:length) / 60 end if ActiveRecord::VERSION::MAJOR >= 5 attribute :name, :string else attr_accessor :name prepend OverrideSongAttributesTheRails4Way end end
Version data entries
11 entries across 11 versions & 1 rubygems