Hello,

I want to implement a CMS framework in Rails. A Page should be viewable in many languages. The Page has a different Name and URL in every language. A Page belongs to a category, which also has a different name and Url for each language. A page has a defined position inside the category and each category has a position in the "category view"

My db scheme

(click)

Rails schema dump
Code:
# This file is autogenerated. Instead of editing this file, please use the
# migrations feature of ActiveRecord to incrementally modify your database, and
# then regenerate this schema definition.

ActiveRecord::Schema.define(:version => 4) do

  create_table "categories", :force => true do |t|
    t.column "pos", :integer, :limit => 10
  end

  create_table "category_translations", :force => true do |t|
    t.column "language_id", :integer, :limit => 10, :default => 0, :null => false
    t.column "category_id", :integer, :limit => 10, :default => 0, :null => false
    t.column "name", :string
    t.column "url", :string
  end

  add_index "category_translations", ["language_id"], :name => "language_FK"
  add_index "category_translations", ["category_id"], :name => "category_FK"

  create_table "languages", :force => true do |t|
    t.column "code", :string
  end

  create_table "page_translations", :force => true do |t|
    t.column "page_id", :integer, :limit => 10, :default => 0, :null => false
    t.column "language_id", :integer, :limit => 10, :default => 0, :null => false
    t.column "name", :string
    t.column "content", :string
    t.column "url", :string
  end

  add_index "page_translations", ["page_id"], :name => "page_FK"
  add_index "page_translations", ["language_id"], :name => "language_FK"

  create_table "pages", :force => true do |t|
    t.column "category_id", :integer, :limit => 10, :default => 0, :null => false
    t.column "pos", :integer, :limit => 10
  end

end
Because the has_and_belongs_to_many relation doesn't allow to store extra data in Mapping Tables I tried using the has_many :trough Association as described in Tutorials
Code:
class CategoryTranslation < ActiveRecord::Base
   belongs_to :category
   belongs_to :language
end

class Category < ActiveRecord::Base
  has_many :category_translations
  has_many :pages
  has_many :languages, :through => :category_translations
end

class Language < ActiveRecord::Base
  has_many :category_translations
  has_many :page_translations
  has_many :categories, :through => :category_translations
  has_many :pages, :through => :page_translations
end

class PageTranslation < ActiveRecord::Base
  belongs_to :page
  belongs_to :language
end

class Page < ActiveRecord::Base
  belongs_to :category
  has_many :page_translations
  has_many :languages, :through => :page_translations  
end
But It doesn't work for me like I expected, I planned to easily fetch pagecontent via
Code:
Language.find_by_code("en").categories.find_by_url("cat1").pages.find_by_url("page123").content
The routes are set up correctly and the DB is populated for tests. I tried with dynamic and static finders, but I can't access the fields in the translation tables.

I hope all this isn't too confusing and my english is well understandable.

Thanks in Advance