Created
July 25, 2013 03:38
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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