Sunday, August 5, 2012

[Rails] Rails Dynamic Finders Return nil

Using Ruby on Rails - sqlite3, rails 3.2.2, ruby 1.9.3p125 (on windows
XP)

Having the record in the db:

Shop.find(123) - returns the shop
Shop.where(:id => 123) - returns the shop

but

Shop.find_by_id(123) returns nil
Shop.find_by_name("some_name") returns nil

So do all the dynamic finders (notice it returns nil for integer value
and for string values).
This happens with every model in every app (even gems)
Just as if I called
Shop.some_missing_method()

Why aren't they defined?

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate