I am using mongoid with devise invitable,
after assigning roles to user I found the following error
"**undefined method `as_document' for Array **" , any suggestions ?
invitable = find_or_initialize_with_error_by(:email, attributes[:email])
invitable.attributes = attributes
# scope_id attribute does not set properly
invitable.roles.map {|r| r.scope_id = attributes[:roles_attributes]["0"][:scope_id]}
if invitable.persisted? && !invitable.invited?
invitable.errors.add(:email, :taken)
elsif invitable.email.present? && invitable.email.match(Devise.email_regexp)
invitable.invite!
end
Whats wrong I am doing ?
This is likely because as_document
doesn't work against an array, only single objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With