Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

[PATCH, TESTED] simple dynamic finders

#3

Hi,

I've just made up some simple dynamic finder support (thanks to iain for this tips).

The implementation comes tested.

As github seems broken now for pulling request, here it is ;-)

My repository is at http://github.com/ZenCocoon/globalize2/tree/master

Commit :

http://github.com/ZenCocoon/globalize2/commit/7f37079c768c28fc9e268...

Hope that helps,

Reported by Sébastien Grosjean - ZenCocoon · January 18th, 2009 @ 11:06 PM

State: new
Milestone: none
Assigned to: Josh H Josh H

Activity

  1. Sébastien Grosjean - ZenCocoon
  2. Sébastien Grosjean - ZenCocoon
    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

    January 20th, 2009 @ 07:23 PM

  3. Sven Fuchs
    Sven Fuchs

    Also looks good to me.

    ZenCocoon, what would "advanced dynamic finders" be?

    January 22nd, 2009 @ 12:57 AM

  4. Sébastien Grosjean - ZenCocoon
    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 fallbacks

    Anyway 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 ?

    January 22nd, 2009 @ 01:27 AM

  5. Josh H
    Josh H
    • State changed from new to resolved

    Applied.

    January 22nd, 2009 @ 03:04 AM

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.