joshmh / globalize2

The second incarnation of Globalize for Rails
http://www.globalize-rails.org/
MIT License
364 stars 57 forks source link

find_by_*! don works (find_by_* - works fine) #24

Open cs3b opened 14 years ago

cs3b commented 14 years ago

Example:

>> Product.find_by_name('iusto nihil sequi debitis saepe')
=> Product id: 1, model_id: 1, name: "aaaa", description: "aaaa", image_file_name: nil, image_content_type: nil, image_file_size: nil, image_updated_at: nil, sku: "LOrTusgeDTI1xQ==", production_status: nil, weight: 0, width: 0, length: 0, height: 0, created_at: "2010-01-15 10:22:39", updated_at: "2010-01-15 10:22:55">
>> Product.find_by_name!('iusto nihil sequi debitis saepe')
ActiveRecord::RecordNotFound: Couldn't find Product with name = iusto nihil sequi debitis saepe
>> I18n.locale                                                                                                                                                                               
=> :en                                                                                                                                                                                       
>> p = Product.find_by_name!('aaaa')
=> Product id: 1, model_id: 1, name: "aaaa", description: "aaaa", image_file_name: nil, image_content_type: nil, image_file_size: nil, image_updated_at: nil, sku: "LOrTusgeDTI1xQ==", production_status: nil, weight: 0, width: 0, length: 0, height: 0, created_at: "2010-01-15 10:22:39", updated_at: "2010-01-15 10:22:55">
>> p.name
=> "iusto nihil sequi debitis saepe"
>> I18n.locale = :pl
=> :pl
>> p.name
=> "aaaa"

it looks like when you try to find with ! - it looks for the last translation that you have saved - but not for currect setted