On 12 jan, 21:22, "Iain Hecker" <[email protected]> wrote:
...
> Of course you can define it yourself, even make it a bit more common:
>
> def method_missing(method, *args)
> if method.to_s =~ /^find_by_\W+$/
> send(:"find_by_#{i18n_attr($1)}")
> else
> super
> end
> end
>
> def i18n_attr(attribute)
> I18n.fallbacks[I18n.locale].map{|tag| tag.to_s}.first
> end
>
> This needs to be cleared up, and tested and so on, it's just as an
> illustration and out of the top of my head.
This looks attractive, I'll dig a bit this way.
> As for intercepting SQL generation, I would much rather see something like:
>
> Post.all(:conditions => { i18n_attr(:title) => "baz" } )
>
> or something like it. My prediction is that applying too much magic to
> the find-method will break things in obscure places and scenarios. It
> might be fine for what you are using, but probably not for a common
> option in globalize.
>
> Note that I haven't even begun to try to find something over multiple
> translations.
I agree, that would make minimal change and keep things easier to
maintain, good exemples of usage and potential complications.
> Tip: To be sure that you've covered all instances it would be best to
> run the Rails ActiveRecord test suite. (i.e. build it into Rails first
> before extracting it into a plugin)
>
> Hope this helps a bit,
It does a lot, thanks a lot for taking time to reply and explain your
point of view.
Warm regards,
--
Sebastien Grosjean - ZenCocoon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"rails-i18n" 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/rails-i18n?hl=en
-~----------~----~----~----~------~----~------~--~---