Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/stateful_enum/active_record_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module ActiveRecordEnumExtension
# end
# end
def enum(definitions, &block)
prefix, suffix = definitions[:_prefix], definitions[:_suffix] if Rails::VERSION::STRING >= '5'
prefix, suffix = definitions[:_prefix], definitions[:_suffix] if ActiveRecord::VERSION::STRING >= '5'
enum = super definitions

if block
Expand Down
12 changes: 8 additions & 4 deletions lib/stateful_enum/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

require 'stateful_enum/active_record_extension'

module StatefulEnum
class Railtie < ::Rails::Railtie
ActiveSupport.on_load :active_record do
::ActiveRecord::Base.extend StatefulEnum::ActiveRecordEnumExtension
if defined?(::Rails::Railtie)
module StatefulEnum
class Railtie < ::Rails::Railtie
ActiveSupport.on_load :active_record do
::ActiveRecord::Base.extend StatefulEnum::ActiveRecordEnumExtension
end
end
end
elsif defined?(::ActiveRecord::Base)
::ActiveRecord::Base.extend StatefulEnum::ActiveRecordEnumExtension
end