Skip to content

Commit

Permalink
Change volumes number and year to integers
Browse files Browse the repository at this point in the history
  • Loading branch information
mwean committed Sep 18, 2013
1 parent 90ebec2 commit 5cfb389
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/admin/volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
config.filters = false

index download_links: false do
column :number, sortable: :number
column :number
column :year
column 'ISBN', :isbn
default_actions
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/volumes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ class VolumesController < ApplicationController
respond_to :html

def index
@volumes = Volume.sort_by_number_desc.decorate
@volumes = Volume.order('number DESC').decorate
end
end
8 changes: 0 additions & 8 deletions app/models/volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,4 @@ class Volume < ActiveRecord::Base

validates :number, presence: true
validates :year, presence: true

def self.sort_by_number_asc
reorder('CAST(volumes.number AS INTEGER) ASC')
end

def self.sort_by_number_desc
reorder('CAST(volumes.number AS INTEGER) DESC')
end
end
6 changes: 3 additions & 3 deletions db/migrate/20130903025247_create_volumes.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class CreateVolumes < ActiveRecord::Migration
def change
create_table :volumes do |t|
t.string :number
t.string :year
t.string :isbn
t.integer :number
t.integer :year
t.string :isbn

t.timestamps
end
Expand Down

0 comments on commit 5cfb389

Please sign in to comment.