I'm able to get a list of all Pages by means of Pages.find(:all), but
the list is not sorted. Pages translated into current locale will show
up in current locale, the rest will show up in fallback locale.
Now I'd like to have the same items listed, but sorted alphabetically
based on the title field.
If I do the following:
Pages.find(:all,
:joins => :globalize_translations,
:order => :title )
all pages show up. If they have not been translated into the currently
set locale they will still show up in the other language. However,
pages translated into both languages shows up twice; both times with
the correct locale. I guess this is because I am now effectively
listing all entries in the Page_translations database table.
If I add the following condition:
Pages.find(:all,
:joins => :globalize_translations,
:conditions => { :pages_translations => { :locale => I18n.locale }},
:order => :title )
each page will be listed once only. But the problem now is that pages
that are not translated into current locale do not show up at all
anymore.
Is there any way of listing all pages ordered by title, in the current
locally if possible, if not in the other locale?
Thanks,
Trond