我正在使用 dwilkie 的foreigner插件用于 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
and game_id
- not agents_id
and games_id
。如何防止 Rails 使列复数?
我在我的enviornment.rb
文件中尝试了以下内容,但没有帮助:
ActiveSupport::Inflector.inflections do |inflect|
inflect.uncountable "agent_id", "game_id"
end