【发布时间】:2019-02-01 23:28:47
【问题描述】:
我在我的 Rails 应用程序中创建了一个模型,一段时间后意识到我忘记添加一些属性,后来通过生成的迁移添加了它们。
我现在意识到schema.rb 中属性列的顺序是它们出现在 ActiveAdmin 中生成的资源视图中的顺序。
当我在 ActiveAdmin 中查看该模型时,我想对列重新排序,我想到的唯一方法是更改数据库中的列顺序。
我查看了here 和here,并尝试使用change_table 或change_column 运行数据库迁移。这没有产生任何变化。
这是我运行的迁移,没有结果:
class Reordercolumn < ActiveRecord::Migration[5.0]
def up
change_table :student_details do |t|
t.change :exact_length, :text, after: :length_of_stay
t.change :returned_home, :boolean, after: :spouse_name
t.change :has_spouse, :boolean, after: :expectation
end
end
end
为了以特定顺序查看 ActiveAdmin 中的属性列,我运行了数据库迁移以更改列,但迁移并未对列重新排序。
【问题讨论】:
标签: ruby-on-rails database activeadmin schema.rb