Skip to content

Commit

Permalink
Add belongs_to optional true to setup_association
Browse files Browse the repository at this point in the history
  • Loading branch information
josephMG committed Feb 20, 2018
1 parent 9da66fe commit fde9d04
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/impressionist/setup_association.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ def include_attr_acc?
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
Expand Down
3 changes: 3 additions & 0 deletions tests/spec/minitest_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
$:.unshift(File.dirname __FILE__)

require 'rails/all'
require 'rails/test_help'
require "minitest/autorun"
require "minitest/pride"
require 'minitest/rails'

0 comments on commit fde9d04

Please sign in to comment.