Skip to content

Instantly share code, notes, and snippets.

@poc7667
Created July 25, 2013 03:38
Show Gist options
  • Save poc7667/6076745 to your computer and use it in GitHub Desktop.
Save poc7667/6076745 to your computer and use it in GitHub Desktop.
How to reset primary key (??) I wanna set my primary key to translate_str , let it be unique in the table, But I've already create the table and have lots of date in the database.
create_table "translates", :force => true do |t|
t.string "translate_str"
t.string "EN"
t.string "DE"
t.string "ES"
t.string "FR"
t.string "IT"
t.string "JP"
t.string "PT"
t.string "CN"
t.string "TW"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
class Translate < ActiveRecord::Base
set_primary_key "translate_str"
validates_presence_of :CN, :DE, :EN, :ES, :FR, :IT, :JP, :PT, :TW, :translate_str
attr_accessible :CN, :DE, :EN, :ES, :FR, :IT, :JP, :PT, :TW, :translate_str, :presence => true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment