Skip to content

Instantly share code, notes, and snippets.

@ccjr
Created December 22, 2008 13:52
Show Gist options
  • Save ccjr/38989 to your computer and use it in GitHub Desktop.
Save ccjr/38989 to your computer and use it in GitHub Desktop.
# Migration
create_table "posts" do |t|
t.string "title_ar"
t.string "title_en"
t.text "body_en"
t.text "body_ar"
end
# Model
class Post < ActiveRecord::Base
translated_attributes :title, :body
end
# View/Controller
@post = Post.first
I18n.locale = 'en'
@post.title #=> post.title_en
I18n.locale = 'ar'
@post.title #=> post.title_ar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment