Skip to content

Commit

Permalink
Merge pull request #480 from godunno/bugfix/preserve-courses-order
Browse files Browse the repository at this point in the history
Preserving courses order.
  • Loading branch information
lunks committed Mar 10, 2015
2 parents 0991129 + 41ed7da commit 9de7ed6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/models/course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class Course < ActiveRecord::Base

before_create :set_access_code

default_scope -> { order(:created_at) }

def self.find_by_identifier!(identifier)
where('access_code = ? OR uuid = ?', identifier, identifier).first!
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddIndexOnCreatedAtToCourses < ActiveRecord::Migration
def change
add_index :courses, :created_at
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20150305150214) do
ActiveRecord::Schema.define(version: 20150310175830) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -87,6 +87,7 @@
t.string "access_code"
end

add_index "courses", ["created_at"], name: "index_courses_on_created_at", using: :btree
add_index "courses", ["organization_id"], name: "index_courses_on_organization_id", using: :btree
add_index "courses", ["teacher_id"], name: "index_courses_on_teacher_id", using: :btree
add_index "courses", ["uuid"], name: "index_courses_on_uuid", unique: true, using: :btree
Expand Down

0 comments on commit 9de7ed6

Please sign in to comment.