We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
My User model already has a subscribed? method indicating whether the user is a paying subscriber of my app.
User
subscribed?
mailkick_
mailkick_subscribed?
What do you think?
module Mailkick module Model def has_subscriptions class_eval do alias_method :subscriptions, :mailkick_subscriptions unless method_defined? :subscriptions alias_method :subscribe, :mailkick_subscribe unless method_defined? :subscribe alias_method :unsubscribe, :mailkick_unsubscribe unless method_defined? :unsubscribe alias_method :subscribed?, :mailkick_subscribed? unless method_defined? :subscribed? has_many :mailkick_subscriptions, class_name: "Mailkick::Subscription", as: :subscriber scope :mailkick_subscribed, ->(list) { joins(:mailkick_subscriptions).where(mailkick_subscriptions: {list: list}) } def mailkick_subscribe(list) mailkick_subscriptions.where(list: list).first_or_create! nil end def mailkick_unsubscribe(list) mailkick_subscriptions.where(list: list).delete_all nil end def mailkick_subscribed?(list) mailkick_subscriptions.where(list: list).exists? end end end end end
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Problem
My
User
model already has asubscribed?
method indicating whether the user is a paying subscriber of my app.Solution
mailkick_
so we get methods likemailkick_subscribed?
subscribed?
, etc) if no such methods exists.What do you think?
Code example
The text was updated successfully, but these errors were encountered: