1

Currently the default Devise generates a user model with an email, the issue is that this would duplicate data. This is because I'm having a contacts table (which has email on it) and the idea is that every user would have a contact but not all contacts would have a user account.

How do I get ActiveRecord to point to a field on another table for the email, is it possible to have a pointer field that would point/redirect to this other table?

I'm also using ActiveAdmin as the CMS.

1 Answer 1

1
class User < ActiveRecord::Base
  belongs_to :contact
  delegate :email, :email=, to: :contact
end
2
  • I expect so. Worth a try.
    – Piers C
    Commented Sep 27, 2017 at 13:32
  • In the end I decided to create hook that will synchronise the email values between then user and the contact objects but I will mark this as correct as this seems like it would work as well.
    – Thermatix
    Commented Sep 28, 2017 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.