Matheus Leite


460 Experience
4 Lessons Completed
0 Questions Solved


Posted in Heroku and Schedule Jobs

I'm implementing a new feature in my app that e-mailing all users every first day of the month. My app is running in Heroku.

My question is: what is the best way to achieve this feature?

We are already using redis with resque to queue job

I don't know how simple_discussion works, but the error by itself tell us what is going on.

Probably, you have a "belongs_to :user", so you cant delete a user because this relation.

I can see two way to handle it:

First -> when deleting a user, delete all forum_threads related to this user. At Users model, add "has_many :forum_threads, dependent: :destroy".

Second -> when deleting a user, nullify user_id at forum_threads table. At Users model, add "has_many :forum_threads, dependent: :nullify"

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

© 2023 GoRails, LLC. All rights reserved.