Skip to content

Instantly share code, notes, and snippets.

@parndt
Created June 10, 2014 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parndt/3207577ecedaea547605 to your computer and use it in GitHub Desktop.
Save parndt/3207577ecedaea547605 to your computer and use it in GitHub Desktop.
Every. Time.
DEPRECATION WARNING: The following options in your Gallery.has_many :gallery_images declaration are deprecated: :order. Please use a scope block instead. For example, the following:
has_many :spam_comments, conditions: { spam: true }, class_name: 'Comment'
should be rewritten as the following:
has_many :spam_comments, -> { where spam: true }, class_name: 'Comment'
@robyurkowski
Copy link

People also forget when defining scopes in the first place to use lambdas. I've seen this about eight gajillion times:

class SomeClass < ActiveRecord::Base
  scope :truthy, where(:some_boolean => true)
end

Cue homophone replacement-level rage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment