Add belongs_to optional true to setup_association

This commit is contained in:
josephMG 2018-02-20 23:16:10 +08:00
parent 9da66fe1e6
commit fde9d042fb
2 changed files with 8 additions and 1 deletions

View File

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

View File

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