Skip to content
New issue

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

MMT-1200 add provider_id validation to drafts #173

Merged
merged 3 commits into from
Oct 27, 2017
Merged

MMT-1200 add provider_id validation to drafts #173

merged 3 commits into from
Oct 27, 2017

Conversation

macrouch
Copy link
Contributor

No description provided.

class RemoveDraftsWithMissingProvider < ActiveRecord::Migration
def change
Draft.all.each do |draft|
draft.destroy if draft.provider_id.nil?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the interest of best practices this type of things is best written using where clauses --
this code loads all the drafts in the database which is easily avoidable using Drafts.where(provider_id: nil).each. While minor, I'd suggest making this change and considering these types of efficiencies in the future.

@macrouch macrouch merged commit b3a957e into master Oct 27, 2017
@macrouch macrouch deleted the MMT-1200 branch October 4, 2023 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants