I'm using the latest thinking_sphinx 1.3.20 and have a concern about
the load_models method in lib/thinking_sphinx/context.rb.
Do to a coding error, I have a model that throws a NameError exception
on load. It looks something like this;
class User < ActiveRecord::Base
validates_length_of :name, :maxiumum => FAT_FINGER # the constant
FAT_FINGER doesn't exist
end
When loading my app (with script/console for example) my models get
loaded through thinking sphinx, and user.rb raises a NameError on
FAT_FINGER which load_models rescues and ignores. I think the
intention of the rescue is to ignore a NameError on the User constant,
but in this case it's ignoring an error that it shouldn't (IMO).
Changing the rescue statement like this might do the trick:
@@ -64,7 +64,7 @@
rescue LoadError
model_name.gsub!(/.*[\/\\]/, '').nil? ? next : retry
rescue NameError
- next
+ $!.name == model_name.camelize ? next : raise
rescue StandardError
STDERR.puts "Warning: Error loading #{file}"
end
What do you think?
I'm also a little skeptical about the rescue of StandardError and am
wondering why that error shouldn't be propagated up as well.
Thanks!
Andy
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en.