Sha256: fe8c3f0d02ff2b09782a901e2c848240a15432b90c45ae079a203fc6ce967ba7
Contents?: true
Size: 963 Bytes
Versions: 35
Compression:
Stored size: 963 Bytes
Contents
class <%= klass %> < <%= Statesman::Utils.rails_5_or_higher? ? 'ApplicationRecord' : 'ActiveRecord::Base' %> include Statesman::Adapters::ActiveRecordTransition # If your transition table doesn't have the default `updated_at` timestamp column, # you'll need to configure the `updated_timestamp_column` option, setting it to # another column name (e.g. `:updated_on`) or `nil`. # # self.updated_timestamp_column = :updated_on # self.updated_timestamp_column = nil <%- unless Statesman::Utils.rails_4_or_higher? -%> attr_accessible :to_state, :metadata, :sort_key <%- end -%> belongs_to :<%= parent_name %><%= class_name_option %>, inverse_of: :<%= table_name %> after_destroy :update_most_recent, if: :most_recent? private def update_most_recent last_transition = <%= parent_name %>.<%= table_name %>.order(:sort_key).last return unless last_transition.present? last_transition.update_column(:most_recent, true) end end
Version data entries
35 entries across 35 versions & 1 rubygems