Hi Matthias,
Sure, but i would approach it differently. Say your Status model
looks like this:
class Status < ActiveRecord::Base
translates :name
end
> class Page < ActiveRecord::Base
> # translates :status_id
> belongs_to :status
# add method to display the page status
def status_display
self.status ? self.status.name : '-'
end
> end
>
Mind you this is quite slow as every time you call status_display a
query is sent of the DB, worse case if you are not using Globalize in
table translations. In my view what may be better is to have a status
field string field in pages model and have it translated using .t, like:
page.status.to_s.t
Anyway, hope this helps?
Greetings,
Juergen
On Jun 6, 2008, at 9:27 AM, Mattias Bodlund wrote:
> Can you also translate foreign keys/relations with Globalize. Lets
> say we have a Page with different statuses in different languages.
>
> Lets say we have Page that belongs_to Status.
>
> class Page < ActiveRecord::Base
> translates :status_id
> belongs_to :status
> end
>
> I get an error trying this:
> undefined method `direction=' for 2:Fixnum
>
> mattias
>
>