我正在使用dwilkie的foreigner插件for rails。我有一個表創建語句看起來像:如何防止Rails將列名「複數化」?
create_table "agents_games", :force => true, :id => false do |t|
t.references :agents, :column => :agent_id, :foreign_key => true, :null => false
t.references :games, :column => :game_id, :foreign_key => true, :null => false
end
然而,這會生成以下SQL:
[4;35;1mSQL (2.7ms)[0m [0mCREATE TABLE "agents_games" ("agents_id" integer NOT NULL, "games_id" integer NOT NULL) [0m
我想要的列被稱爲agent_id
和game_id
- 不agents_id
和games_id
。如何防止Rails將列複數化?
我想在我的enviornment.rb
文件下面,這並沒有幫助:
我在ActiveSupport :: Inflector.inflections中添加了| inflect | inflect.uncountable「agent_id」,「game_id」 end',但Rails仍然適用於複數列。 – Mike 2010-03-12 00:43:36