You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure about our use of the default_scope in app/models/article.rb, app/models/payment_method.rb, app/models/subscription_offer.rb. It sure is easier to query later, however it also has some unexpected effects as it changes a new Article to set deleted_at: nil by default (though in this case this is the value we expect).
It can also be hard to cancel or override correctly, for example Article.first.refunds.unscoped will remove the WHERE refunds.article_id = $article_id constraint and show you all refunds, Article.first.unscoped.refunds doesn't change anything compared to without unscoped, and the correct thing is Article.unscoped.first.refunds. Also if you do Article.where(name: 'Câble').unscoped, the where clause is removed because unscoped removes everything before it.
For now it doesn't seem to cause any issue for us, so your call.
Not sure about our use of the
default_scope
inapp/models/article.rb
,app/models/payment_method.rb
,app/models/subscription_offer.rb
. It sure is easier to query later, however it also has some unexpected effects as it changes a new Article to setdeleted_at: nil
by default (though in this case this is the value we expect).It can also be hard to cancel or override correctly, for example
Article.first.refunds.unscoped
will remove theWHERE refunds.article_id = $article_id
constraint and show you all refunds,Article.first.unscoped.refunds
doesn't change anything compared to without unscoped, and the correct thing isArticle.unscoped.first.refunds
. Also if you doArticle.where(name: 'Câble').unscoped
, thewhere
clause is removed becauseunscoped
removes everything before it.For now it doesn't seem to cause any issue for us, so your call.
More reading:
The text was updated successfully, but these errors were encountered: