diff --git a/lib/impressionist/setup_association.rb b/lib/impressionist/setup_association.rb index 1bc5227..b5c3c16 100644 --- a/lib/impressionist/setup_association.rb +++ b/lib/impressionist/setup_association.rb @@ -12,7 +12,11 @@ module Impressionist end def define_belongs_to - receiver.belongs_to(:impressionable, :polymorphic => true) + if ::Rails::VERSION::MAJOR.to_i >= 5 + receiver.belongs_to(:impressionable, :polymorphic => true, :optional => true) + else + receiver.belongs_to(:impressionable, :polymorphic => true) + end end def set diff --git a/tests/spec/minitest_helper.rb b/tests/spec/minitest_helper.rb index eeb22af..e4f904f 100644 --- a/tests/spec/minitest_helper.rb +++ b/tests/spec/minitest_helper.rb @@ -1,4 +1,7 @@ $:.unshift(File.dirname __FILE__) +require 'rails/all' +require 'rails/test_help' require "minitest/autorun" require "minitest/pride" +require 'minitest/rails'