Ask A Question

Notifications

You’re not receiving notifications from this thread.

Noticed V2 how to joins(:events)

Walther Diechmann asked in Gems / Libraries

Fearing this will run shivers of back in kindergarden I do apologize in advance for asking this level of n00b-ness question but I simply cannot wriggle my head around the Noticed::Notification (noticed_notifications) and Noticed::Event (noticed_events) models (tables) in my quest for distilling the number of notifications (delivered by TaskNotifier) users have received pertaining to tasks :(

I'm leaning towards Current.user.notifications.joins(:something).where(something: { record_type: "Task" } ) but sadly no matter what combo of events, noticed, more, I use all I get back is some flavour of #<ActiveRecord::ConfigurationError: Can't join 'Noticed::Notification' to association named 'noticed_events';

Reply

I'll let myself out!

Current.user.tasks.first_tasks.uncompleted.each do |task|
  task.notify unless task.notifications.where( recipient: Current.user).any?
end

- and I am aware of the "less than optimal" solution (eg with a few hundred users each with a couple dozen tasks this sick monster will run for years on end) :sunglasses:

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 88,096+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.