Ok. I have identified an I18N issue caused by ThinkingSphinx and I
would appreciate thoughts on what is causing the issue. It has driven
me crazy all day. The problem wasn't obvious due to a large number of
recent changes in my app, but I have finally tracked the problem to
ThinkingSphinx.

I use TS in my app and I use i18n extensively in a large app. I
upgraded to the latest TS a short while ago (I was running my fork but
switched to the main one). When running my unit tests today, many of
my validation tests started failing with messages about "translation
missing". This is odd because all of my tests had been passing.

After many hours of debugging I have shown that TS is causing the
problem. I have created a sample application that demonstrates the
problem. ( http://files.me.com/drmarklane/rrxgcm )

In the sample app I have a simple User model with the following sample
validations:

  validates_presence_of :first_name,
             :message => I18n.t
('users.errors.first_name_cant_be_blank')
  validates_format_of   :last_name, :with=>/[^ \t\n\r\f\v ]/,
             :message=>"#{I18n.t
('users.errors.last_name_wrong_format')}"

if you log in to the console then do:
>> u = User.new
=> #<User id: nil, first_name: nil, last_name: nil, created_at: nil,
updated_at: nil>
>> u.valid?
=> false
>> u.errors
=> #<ActiveRecord::Errors:0x21d0f2c @errors={"first_name"=>
["translation missing: en, users, errors, first_name_cant_be_blank"],
"last_name"=>["translation missing: en, users, errors,
last_name_wrong_format"]}, @base=#<User id: nil, first_name: nil,
last_name: nil, created_at: nil, updated_at: nil>>

Notice the "translation missing" errors in the errors hash. Any unit
tests will also fail because of the translation missing errors. Adding
default i18n settings in config.rb doesn't help.

If you remove ThinkingSphinx, log out of the console, then repeat the
above steps you will get:

>> u = User.new
=> #<User id: nil, first_name: nil, last_name: nil, created_at: nil,
updated_at: nil>
>> u.valid?
=> false
>> u.errors
=> #<ActiveRecord::Errors:0x2357da0 @errors={"first_name"=>["Your
first name can't be blank"], "last_name"=>["Your first name is the
wrong format"]}, @base=#<User id: nil, first_name: nil, last_name:
nil, created_at: nil, updated_at: nil>>

which is correct. Note that TS is not even called in the sample app.
Simply placing TS in the plugins folder causes the problem.

Does anyone have any ideas as to the cause of this issue? I think the
issue is related to the class loading by TS. I would appreciate your
advice.

Thanks!

DrMark

PS. Pat, your copy of not-a-mock doesn't build unless you set the gem
version of Rails to 2.2.2

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to