我想重命名一个表...(任何表.)
我试过这行代码:
ActiveRecord::ConnectionAdapters::SchemaStatements.rename_table(old_name, new_name)
Run Code Online (Sandbox Code Playgroud)
这是奇怪的事情.我知道我第一次使用它,但现在我得到了这个错误:ActiveRecord :: ConnectionAdapters :: SchemaStatements:模块的未定义方法`rename_table'
有什么我需要设置的吗?
我有这个模型和多对多关联:通过:
class RailwayStation < ActiveRecord::Base
has_many :railway_stations_routes
has_many :routes, through: :railway_stations_routes
end
class Route < ActiveRecord::Base
has_many :railway_stations_routes
has_many :railway_stations, through: :railway_stations_routes
end
class RailwayStationsRoute < ActiveRecord::Base
belongs_to :railway_station
belongs_to :route
end
Run Code Online (Sandbox Code Playgroud)
我添加了列st_index:
add_column :railway_stations_routes, :st_index, :integer
Run Code Online (Sandbox Code Playgroud)
对于路线中的索引站,但我不明白如何从路线视图形式更改它:
ul
- @route.railway_stations.each do |railway_station|
li = railway_station.title
= ????
Run Code Online (Sandbox Code Playgroud)