列活动支架排序

时间:2017-07-18 18:08:33

标签: ruby-on-rails ruby activescaffold

我正在尝试使用活动脚手架,Rails 5.1.2和Ruby 2.3.3p222以自定义顺序列出/排序我的列。

迁移如下:

class CreateResources < ActiveRecord::Migration[5.1]
  def change
    create_table :resources do |t|
      t.string :firstname
      t.string :surname
      t.date :date_of_birth
      t.string :identity_number
      t.string :nationality
      t.string :state_province
      t.date :interview_date
      t.string :available
      t.string :home_phone
      t.string :mobile_phone

      t.timestamps
    end
  end
end

我添加了列,迁移如下:

class AddColumnsToResources < ActiveRecord::Migration[5.1]
  def change
    add_column :resources, :expected_salary, :string
    add_column :resources, :current_ctc, :string
    add_column :resources, :years_of_experience, :string
    add_column :resources, :notice_period, :string
  end
end

然后我使用回形针在表格中添加附件:

class AddAttachmentAttachmentToResources < ActiveRecord::Migration[5.1]
  def self.up
    change_table :resources do |t|
      t.attachment :attachment
    end
  end

  def self.down
    remove_attachment :resources, :attachment
  end
end

我需要对列进行排序,使它们按以下顺序显示:

  1. firstame
  2. 姓氏
  3. 身份证号码
  4. ...

0 个答案:

没有答案