我正在使用Rails的Agile Web开发来学习Rails.在早期的章节中,作者创建了脚手架,然后开始研究迁移.在他的迁移中,有一个"向上"和"向下"的方法,而我在迁移中只有一个"改变"方法.作者正在使用Rails 3.05(或类似的东西),我使用3.1,但是,我不认为这是解释,因为使用另一本书但相同版本的Rails我记得创建一个具有"向上"的迁移"向下"方法......
那么,两个问题,
a)我在迁移中使用不同方法名称的原因是什么?
b)是否会影响功能?
我的移民
class CreateProducts < ActiveRecord::Migration
def change
create_table :products do |t|
t.string : title
t.text :description
t.string :image_url
t.decimal :price, :precision => 8, :scale => 2
t.timestamps
end
end
end
Run Code Online (Sandbox Code Playgroud)
书籍迁移
class CreateProducts < ActiveRecord::Migration
def self.up
create_table :products do |t|
t.string :title
t.text :description
t.string :image_url
t.decimal :price, :precision => 8, :scale => 2
t.timestamps
end
end
def self.down
drop_table :products
end
end
Run Code Online (Sandbox Code Playgroud) 我已经在锚窗格中创建了fxml文件,但每次我点击按钮我都会在新框架中获得下一个fxml我希望它在同一框架中打开
public void baropen(ActionEvent event) {
// handle the event here
BorderPane bp = new BorderPane();
bp.setPadding(new Insets(10, 50, 50, 50));
Stage stage = new Stage();
Scene scene ;
// scene= new Scene(root);
scene = new Scene(bp);
stage.setScene(scene);
stage.show();
try {
new RecBar().start(stage);
} catch (Exception ex) {
Logger.getLogger(RecController.class.getName()).log(Level.SEVERE, null,ex);
}
}
Run Code Online (Sandbox Code Playgroud)