Giter Club home page Giter Club logo

Comments (5)

codeglover avatar codeglover commented on May 21, 2024 2

He doesn't want to pick a particular user, he wants to use a different model completely. He is not tracking users, he is tracking subscribers. I too have a Subscriber model that I wish to track. As mentioned before, mailkick handles this perfectly but I cannot seem to do it with this gem.

from ahoy_email.

ankane avatar ankane commented on May 21, 2024

@ollieglass user is polymorphic, so it already supports any user model. https://github.com/ankane/ahoy_email/blob/master/app/models/ahoy/message.rb#L5

from ahoy_email.

ollieglass avatar ollieglass commented on May 21, 2024

I see... so I say my model (Subscriber) has_many :messages, as: :user... and that won't conflict with another model called User?

Won't this line require the model to be called User?

user: proc { |message, mailer| (message.to.size == 1 ? User.where(email: message.to.first).first : nil) rescue nil },

Sorry if I'm not getting it!

from ahoy_email.

CollinGraves avatar CollinGraves commented on May 21, 2024

@ollieglass that shouldn't be an issue, although the naming of this polymorphic relationship is rather awkward. And yes, your semantics are correct there. Although I'd worry about using this on a Subscriber class when you also have a User class. Things could get awkward pretty quickly.

You wonder if something like: belongs_to :messageable, polymorphic: true wouldn't be better, in which case you could include a global override to specify the model of your choice.

I just think it's weird to technically have a User class that also has a "User" for its user_type. :)

from ahoy_email.

ankane avatar ankane commented on May 21, 2024

@ollieglass that's the default user option, but you can pass whatever you'd like to track user: any_user.

from ahoy_email.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.