app/models/invite.rb in invitation-0.4.3 vs app/models/invite.rb in invitation-0.4.4
- old
+ new
@@ -3,10 +3,16 @@
# to (more) securely identify the invite when a new user clicks to register.
#
class Invite < ActiveRecord::Base
belongs_to :invitable, polymorphic: true
belongs_to :sender, class_name: Invitation.configuration.user_model_class_name
- belongs_to :recipient, class_name: Invitation.configuration.user_model_class_name
+
+ # Rails >= 5 makes belongs_to association required by default
+ if Rails::VERSION::MAJOR >= 5
+ belongs_to :recipient, class_name: Invitation.configuration.user_model_class_name, optional: true
+ else
+ belongs_to :recipient, class_name: Invitation.configuration.user_model_class_name
+ end
before_create :generate_token
before_save :set_email_case, on: :create
before_save :check_recipient_existence