在Rails中的另一列之前添加一列 [英] Adding a column before another one in Rails
本文介绍了在Rails中的另一列之前添加一列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在表格的最前面放置一列,我知道你可以做
I'm looking to put a column at the front of my table I know you can do
add_column :customer, :first_name, after: :last_name
但是有一种方法可以执行:之前
?
but is there a way to do :before
?
推荐答案
您可以使用以下方法在表格的前面插入一列:first
选项:
You're able to insert a column at the front of your table by using the :first
option:
add_column :table_name, :column_name, :column_type, first: true
您仍然可以使用:after
处理其他所有定位案例。
You can still use :after
to handle all other positioning cases.
这篇关于在Rails中的另一列之前添加一列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文