Skip to content

Instantly share code, notes, and snippets.

@dissolved
Created May 12, 2011 16:17
Show Gist options
  • Save dissolved/968850 to your computer and use it in GitHub Desktop.
Save dissolved/968850 to your computer and use it in GitHub Desktop.
Problem with Dynamic Finders in seeds.rb
# db/seeds.rb
orig = Security.create!(symbol:'NFLX', name:'Overvalued Content Provider')
puts Security.all
puts orig.symbol
s = Security.find_by_symbol(orig.symbol)
puts s.nil? ? "not found" : "found"
s = Security.find(orig.id)
puts s.nil? ? "not found" : "found"
# Output
# Overvalued Content Provider (NFLX)
# NFLX
# not found
# found
@dissolved
Copy link
Author

I've reproduced this output so far with both SQLite3 and MySQL. Using Rails 3.0.7 and Ruby 1.9.2p0

@dissolved
Copy link
Author

Eureka... the annotate gem was installed... and within it, is the following code:
module ::ActiveRecord
class Base
def self.method_missing(name, *args)
# ignore this, so unknown/unloaded macros won't cause parsing to fail
end
end
end

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