Add user to exercise_collection
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
class ExerciseCollection < ActiveRecord::Base
|
class ExerciseCollection < ActiveRecord::Base
|
||||||
|
|
||||||
has_and_belongs_to_many :exercises
|
has_and_belongs_to_many :exercises
|
||||||
|
belongs_to :user, polymorphic: true
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
"#{I18n.t('activerecord.models.exercise_collection.one')}: #{name} (#{id})"
|
"#{I18n.t('activerecord.models.exercise_collection.one')}: #{name} (#{id})"
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
class AddUserToExerciseCollection < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_reference :exercise_collections, :user, polymorphic: true, index: true
|
||||||
|
end
|
||||||
|
end
|
@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20171122124222) do
|
ActiveRecord::Schema.define(version: 20171210172208) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@ -105,8 +105,12 @@ ActiveRecord::Schema.define(version: 20171122124222) do
|
|||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.boolean "use_anomaly_detection", default: false
|
t.boolean "use_anomaly_detection", default: false
|
||||||
|
t.integer "user_id"
|
||||||
|
t.string "user_type"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_index "exercise_collections", ["user_type", "user_id"], name: "index_exercise_collections_on_user_type_and_user_id", using: :btree
|
||||||
|
|
||||||
create_table "exercise_collections_exercises", id: false, force: :cascade do |t|
|
create_table "exercise_collections_exercises", id: false, force: :cascade do |t|
|
||||||
t.integer "exercise_collection_id"
|
t.integer "exercise_collection_id"
|
||||||
t.integer "exercise_id"
|
t.integer "exercise_id"
|
||||||
|
Reference in New Issue
Block a user