Skip to content

Commit 31c1dd2

Browse files
committed
Add file name to ExerciseFile model
- includes migration and schema.rb changes - also added ExerciseFile#full_file_name as a required helper to concat file's base name and extension (filetype) (#17)
1 parent 55d81ce commit 31c1dd2

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

app/models/exercise_file.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
class ExerciseFile < ActiveRecord::Base
22
belongs_to :exercise
3+
4+
def full_file_name
5+
"#{self.file_name}.#{self.filetype}"
6+
end
7+
38
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddFileNameToExerciseFile < ActiveRecord::Migration
2+
def change
3+
add_column :exercise_files, :file_name, :string
4+
end
5+
end

db/schema.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended that you check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(version: 20160212110642) do
14+
ActiveRecord::Schema.define(version: 20160213122258) do
1515

1616
create_table "account_links", force: :cascade do |t|
1717
t.datetime "created_at", null: false
@@ -109,6 +109,7 @@
109109
t.integer "exercise_id"
110110
t.datetime "created_at", null: false
111111
t.datetime "updated_at", null: false
112+
t.string "file_name"
112113
end
113114

114115
add_index "exercise_files", ["exercise_id"], name: "index_exercise_files_on_exercise_id"

0 commit comments

Comments
 (0)