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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 5 August 2012 13:30, yaniv pr <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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()That would not return nil, it would give an exception. Which is it in your case? Also you did not reply to my question (on the core list) about what is shown in the log when you call find_by_id. Does it execute some sql? If so then what? Colin> > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Colin Law wrote in post #1071355:> On 5 August 2012 13:30, yaniv pr <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> 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() > > That would not return nil, it would give an exception. Which is it in > your case? > Also you did not reply to my question (on the core list) about what is > shown in the log when you call find_by_id. Does it execute some sql? > If so then what? > > ColinSorry, I can''t seem to find my own question and you reply... There''s no exception, just nil, as if you call a non-existing method in the console Will check the log soon, good idea. Appreciate your help! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Solved. Either by upgrading to rails 3.2.6 or by removing ''annotated_model'' gem. Thanks. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.