Merge pull request #264 from josephMG/optional_belongs_to

Add belongs_to optional true to setup_association
This commit is contained in:
John McAliley 2018-04-16 10:56:58 -04:00 committed by GitHub
commit 1402073ce1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -12,7 +12,11 @@ module Impressionist
end end
def define_belongs_to 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 end
def set def set

View File

@ -1,4 +1,7 @@
$:.unshift(File.dirname __FILE__) $:.unshift(File.dirname __FILE__)
require 'rails/all'
require 'rails/test_help'
require "minitest/autorun" require "minitest/autorun"
require "minitest/pride" require "minitest/pride"
require 'minitest/rails'