Ashish.S
Ashish.S

Reputation: 41

Sort columns active scaffold

I am trying to list/order my columns in a custom order with active scaffold, Rails 5.1.2 and Ruby 2.3.3p222.

Migration as follows:

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

And I have added columns, the migration is as follows:

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

I then used paperclip to add an attachment to the table:

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

I need to sort my columns so they appear in the following order:

  1. firstame
  2. surname
  3. identity number
  4. ...

Upvotes: 0

Views: 240

Answers (0)

Related Questions