diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 66c93e423a6..26fd64cdb40 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -47,7 +47,7 @@ def course_params params.require(:course).permit( :title, :description, - :is_opened, + :open, category_ids: [] ) end diff --git a/app/views/courses/_course.html.slim b/app/views/courses/_course.html.slim index cd77024412c..a79c8e4266d 100644 --- a/app/views/courses/_course.html.slim +++ b/app/views/courses/_course.html.slim @@ -1,10 +1,10 @@ .col-xxl-3.col-xl-4.col-lg-4.col-md-6.col-xs-12 - .courses-item(id="course_#{course.id}" class="#{course.open_course ? 'is-opened' : 'is-closed'}") + .courses-item(id="course_#{course.id}" class="#{course.open ? 'is-opened' : 'is-closed'}") .courses-item__inner.a-card header.courses-item__header h3.courses-item__title = link_to [course, :practices], class: 'courses-item__title-link' do - - if admin_login? && !course.open_course + - if admin_login? && !course.open .courses-item__title-icon.is-closed | 非表示 span.courses-item__title-label diff --git a/app/views/courses/_form.html.slim b/app/views/courses/_form.html.slim index ed3b4aa80c2..0a3ea7c7557 100644 --- a/app/views/courses/_form.html.slim +++ b/app/views/courses/_form.html.slim @@ -10,7 +10,7 @@ .col-md-6.col-xs-12 = f.label 'コースを表示する', class: 'a-form-label' label.a-on-off-checkbox.is-md - = f.check_box :is_opened, class: 'is-open-checkbox' + = f.check_box :open, class: 'is-open-checkbox' span#checkbox-open-course .form-item .row.js-markdown-parent diff --git a/app/views/courses/index.html.slim b/app/views/courses/index.html.slim index 1cfcb19e462..e583734e348 100644 --- a/app/views/courses/index.html.slim +++ b/app/views/courses/index.html.slim @@ -18,4 +18,4 @@ header.page-header - if current_user&.admin? = render @courses.order(:created_at) - else - = render @courses.where(open_course: true).order(:created_at) + = render @courses.where(open: true).order(:created_at) diff --git a/db/migrate/20210805050956_add_open_course_to_courses.rb b/db/migrate/20210805050956_add_open_course_to_courses.rb deleted file mode 100644 index e8e592dd684..00000000000 --- a/db/migrate/20210805050956_add_open_course_to_courses.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddOpenCourseToCourses < ActiveRecord::Migration[6.1] - def change - add_column :courses, :open_course, :boolean, default: false, null: false - end -end diff --git a/db/migrate/20210916061442_rename_open_course_column_to_courses.rb b/db/migrate/20210916061442_rename_open_course_column_to_courses.rb deleted file mode 100644 index c99f542a8f3..00000000000 --- a/db/migrate/20210916061442_rename_open_course_column_to_courses.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RenameOpenCourseColumnToCourses < ActiveRecord::Migration[6.1] - def change - rename_column :courses, :open_course, :is_opened - end -end diff --git a/db/migrate/20210923053650_add_open_to_courses.rb b/db/migrate/20210923053650_add_open_to_courses.rb new file mode 100644 index 00000000000..b55f12d425d --- /dev/null +++ b/db/migrate/20210923053650_add_open_to_courses.rb @@ -0,0 +1,5 @@ +class AddOpenToCourses < ActiveRecord::Migration[6.1] + def change + add_column :courses, :open, :boolean, default: false, null: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 364fe81d9ac..04d8c172c90 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_09_16_061442) do +ActiveRecord::Schema.define(version: 2021_09_23_053650) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -140,7 +140,7 @@ t.text "description", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.boolean "is_opened", default: false, null: false + t.boolean "open", default: false, null: false end create_table "courses_categories", force: :cascade do |t|