Hello, Using 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 same for find_by_name, etc. So do all the dynamic finders (notice it returns nil for integer value and for string values) Why aren''t they defined? Thanks! -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/ln0jQMMdZpgJ. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Hi,> Shop.find(123) - returns the shop > Shop.where(:id => 123) - returns the shop > but > Shop.find_by_id(123) returns nil > same for find_by_name, etc.Here on Mac OS X with PostgreSQL, Shop.find_by_id and find_by_name return the expected instance. Could it be linked to sqlite3 or Windows? -- Thibaut -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On 2 August 2012 20:12, yaniv pr <yanivpr@gmail.com> wrote:> Hello, > > Using 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 > same for find_by_name, etc.What does the log show for the sql used when you do those? Colin> > So do all the dynamic finders (notice it returns nil for integer value and for string values) > > Why aren''t they defined? > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/ln0jQMMdZpgJ. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
The first thing you should do is to make sure this is a Rails bug. For example, you should create a fresh application with no other gem and see if the problem arises. In that case, you could push the application source to GitHub so that others could try to replicate the behavior. If you can''t replicate this behavior in a fresh application then there is probably some gem changing the behavior of ActiveRecord. In that case you could try publishing your Gemfile.lock to a GitHub gist or a similar service and posting the link (probably on rails-talk) so that others could try to help you to identify which gem is introducing this bug. Finally, debugging in Ruby is pretty easy. Just put a breakpoint (debugger method) before the find_by_id statement and step into it. You''ll be able to investigate the stacktrace on each step to see why it is returning nil. This will certainly help you to investigate what is causing the issue. If you find a bug in ActiveRecord, submitting a pull request with a test case for it would get your bug fixed soon. Hope that helps, Rodrigo. Em 02-08-2012 16:12, yaniv pr escreveu:> Hello, > > Using 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 > same for find_by_name, etc. > > So do all the dynamic finders (notice it returns nil for integer value and for string values) > > Why aren''t they defined? > > Thanks! >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.