[PATCH, TESTED] simple dynamic finders
-
Sébastien Grosjean - ZenCocoon
- Assigned user set to Josh H
-
Sébastien Grosjean - ZenCocoon
- Title changed from pull_request for simple dynamic finders, tested to [PATCH, TESTED] simple dynamic finders
- Tag changed from dynamic, finders, tested to dynamic, finders, patched, tested
-
Sven Fuchs
Also looks good to me.
ZenCocoon, what would "advanced dynamic finders" be?
-
Sébastien Grosjean - ZenCocoon
Maybe something like :
Book Model
translate :title
Controller
Book.find_by_title_and_author('foo', 'bar')
Being able to use all dynamic finders like we do without globalize.
I guess it need patching around :
http://github.com/rails/rails/blob/39e1ac658efc80e4c54abef4f1c7679e...
http://github.com/rails/rails/blob/39e1ac658efc80e4c54abef4f1c7679e...= Looks like When an attribute is not found in the model db
Then check if present in the translation ones
If so, joins the table and check the attribute with i18n_attr and locale fallbacksAnyway things like the following example would already work but still complex for dynamic finders like showed before :
Book.find(:first, :joins => :globalize_translations, :conditions => [Book.i18n_attr('name')+" = ? AND "+Book.i18n_attr('locale')+" IN (?) AND author = ?", 'foo', I18n.fallbacks[I18n.locale].map{|tag| tag.to_s}, 'bar'])
What do you think about it ?
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.