我有一个现有的模型' micropost'我发现该模型有更好的名称以适合我的应用。重命名微博'更好的方法是什么?模特到故事'模型而不影响其指数?我正在使用Rails 5.0.0.rc1。迁移代码段为:
class CreateMicroposts < ActiveRecord::Migration
def change
create_table :microposts do |t|
t.text :content
t.references :user, index: true
t.timestamps null: false
end
add_index :microposts, [:user_id, :created_at]
end
end
答案 0 :(得分:0)
1.进行迁移以将数据库表名从微博改为故事。
CSensoryFrame SF;
CActionCollection actionCol;
CPose2D actualOdometryReading(0.0f, 0.0f, DEG2RAD(.0f));
// Prepare the "options" structure:
CActionRobotMovement2D actMov;
CActionRobotMovement2D::TMotionModelOptions opts;
opts.modelSelection = CActionRobotMovement2D::mmThrun;
opts.thrunModel.alfa3_trans_trans = 0.10f;
// Create the probability density distribution (PDF) from a 2D odometry reading:
actMov.computeFromOdometry(actualOdometryReading, opts);
actionCol.insert(actMov);
CObservation2DRangeScanPtr myObs = CObservation2DRangeScan::Create();
myObs->scan = scan; // = [1,0]
myObs->validRange = vranges; // = [1,1]
myObs->aperture = 2 * M_PI;
SF.insert(myObs);
2.手动将Active Record模型类更改为Story
答案 1 :(得分:0)
在控制台上运行命令:
$ rails g migration RenameMicropostToStory
修改迁移文件:
class RenameMicropostToStory < ActiveRecord::Migration
def change
rename_table :microposts, :stories
end
end
然后,
$ rake db:migrate