ruby-on-rails – 如何在Rails应用程序的数据库中排列列的顺序?
发布时间:2020-12-17 01:46:06 所属栏目:百科 来源:网络整理
导读:我最近使用Rails迁移添加了:title列: class AddTitleToMicroposts ActiveRecord::Migration def change add_column :microposts,:title,:string endend 我注意到,当我执行user.microposts时它出现在最后:在控制台中: = [#Micropost id: 1,content: "test
我最近使用Rails迁移添加了:title列:
class AddTitleToMicroposts < ActiveRecord::Migration def change add_column :microposts,:title,:string end end 我注意到,当我执行user.microposts时它出现在最后:在控制台中: => [#<Micropost id: 1,content: "test",user_id: 1,created_at: "2012-01-25 15:34:30",updated_at: "2012-01-25 15:34:30",title: nil>] 有没有办法安排标题栏的顺序?比如说,把它放在:content列之前? 解决方法
在架构中重新排列它们并执行rake db:schema:load
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |