globalize2 icon indicating copy to clipboard operation
globalize2 copied to clipboard

reflect_on_all_validations ???

Open khelben opened this issue 14 years ago • 4 comments

On the following line: you use the method 'reflect_on_all_validations' but this method is nowhere defined (besides a plugin but this isn't installed)

http://github.com/joshmh/globalize2/blob/master/lib/globalize/active_record.rb#L106

This breaks the named scope (and others) which call the method ModelClass.required_attributes.

khelben avatar Apr 26 '10 21:04 khelben

I submitted a pull request which added support to set required_attributes. It was accepted, so you can set required_attributes and it should work without reflect_on_all_validations

scambra avatar Apr 28 '10 14:04 scambra

still not working for me.

NameError: undefined local variable or method `reflect_on_all_validations' for #Class:0xb6cc11d4

btw, i had another issue. given i have model Post and this Post has 2 translations (:en, :'pt-BR') for "title" and I am on I18n.locale = 'en' by default.

p = Post.first(:include => :translations, :conditions => ["post_translations.locale = ?", 'en'])

p.name returns 'title'

p = Post.first(:include => :translations, :conditions => ["post_translations.locale = ?", 'pt-BR'])

p.name returns nil

why if i have both translations on my db? cant figure out it and need a help.

bernardeli avatar Jun 15 '10 15:06 bernardeli

Have you set required attributes in your class? The patch was a method to set required_attributes so reflect_on_all_validations won't be called. self.required_attributes = [:name]

scambra avatar Jun 16 '10 07:06 scambra

thx man!

even though, it is still not working for me.. such as: my I18n.locale is set to :'pt-BR' by default

p = Post.with_translations(:'pt-BR').first p.name returns OK in pt-BR, as it should.

p = Post.with_translations(:en).first p.name returns nil.. and I have both translations on my db.

if I do it hardcoded, such as: p = Post.first(:include => :translations, :conditions => ["post_translations.locale = 'en'"]) p.name returns nil again.

I cant find out my issue with this. thx for your help.

bernardeli avatar Jun 16 '10 13:06 bernardeli