Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reflect_on_all_validations ??? #28

Open
khelben opened this issue Apr 26, 2010 · 4 comments
Open

reflect_on_all_validations ??? #28

khelben opened this issue Apr 26, 2010 · 4 comments

Comments

@khelben
Copy link

khelben commented Apr 26, 2010

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.

@scambra
Copy link
Contributor

scambra commented Apr 28, 2010

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

@bernardeli
Copy link

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.

@scambra
Copy link
Contributor

scambra commented Jun 16, 2010

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]

@bernardeli
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants