English 中文(简体)
关于铁路迁移和同步观点的问题
原标题:Question regarding rails migration and synchronizing views

I am a Rails beginner and trying to understand how rails migration works. I have created a scaffold like:

script/generate scaffold Item col1:string col2:text
rake db:migrate

我愿用移民补充另一个栏4:

我建立了以下移民:

class AddCol4 < ActiveRecord::Migration
  def self.up
        add_column      :items, :col4, :numeric
        Item.reset_column_information
  end

  def self.down
        remove_column   :items, :col4
  end
end

When I run rake db:migrate the new column gets added. However the view is out of sync. Am I supposed to manually add the new column to the view? Is there a way to auto-regenerate the model/view using the new table columns?

Sorry, it is a basic question but from my experience with other frameworks, it should have been automatic. The rails guide on migration does not make this obvious regarding how the synchronization is supposed to work after you perform a migration.

最佳回答

不幸的是,你将需要人工修改观点。 采用<条码>文字/代谢双手法指令即可得出这一看法。 移民只是改变了数据库。 从技术上讲,你可以重新掌握手法,并重新提出看法。 但是,如果你走这条路,你仍需要具体说明你想要的所有栏目。 你可以在这里和那里补充一些内容。

如果你处于早期发展阶段,你就可以走这条路。 简单操作

script/destroy scaffold Item

之后再行

script generate scaffold Item col1:string col2 string col3:numeric

现有的一些有活力的耳光延伸,例如ActiveScafridge。 如果你正在创造只有少数用户会看到的东西,但我建议采用超文本字节,因为这将永远展现出你所希望的途径。

我似乎找不到任何其他充满活力的粉碎块。 通常只有少数......

问题回答

暂无回答




相关问题
Copy data from Access to SQL

I am in the process of migrating an existing Access database to a SQL database with a web front-end. I have successfully copied the database to SQL using the SQL Server Migration tool and am working ...

MongoMapper and migrations

I m building a Rails application using MongoDB as the back-end and MongoMapper as the ORM tool. Suppose in version 1, I define the following model: class SomeModel include MongoMapper::Document ...

Switching to WPF. Is it time?

I m considering switching from MFC to WPF. My first concern is that there are too many users who don t have .NET with WPF installed yet. Can anybody point to a source containing the WPF penetration ...

rake db:migrate running all migrations correctly

I m fairly new to Ruby on Rails here. I have 2 migrate files that were provided. The first one, prefixed with 001, creates a table and some columns for that table. The next migrate file, prefixed ...

Migrate Java Applet to what/where?

I am reviewing currently a medium size code base (around 30K LOC) which uses a huge Applet and interfaces with other systems. It s a tool to create custom labels, so we need drag-n-drop and other ...

热门标签