From da23cc22aa44c9eed18545b493ce646058e4e168 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Fri, 2 Feb 2018 14:38:28 +0100 Subject: [PATCH] add the required integer column and the increment statement when featured --- app/controllers/exercises_controller.rb | 3 +++ ...80202132034_add_times_featured_to_request_for_comments.rb | 5 +++++ db/schema.rb | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20180202132034_add_times_featured_to_request_for_comments.rb diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index fa48363e..7d4d2c43 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -416,6 +416,9 @@ class ExercisesController < ApplicationController flash[:notice] = I18n.t('exercises.submit.full_score_redirect_to_rfc') flash.keep(:notice) + # increase counter 'times_featured' in rfc + rfc.increment!(:times_featured) + respond_to do |format| format.html {redirect_to(rfc)} format.json {render(json: {redirect: url_for(rfc)})} diff --git a/db/migrate/20180202132034_add_times_featured_to_request_for_comments.rb b/db/migrate/20180202132034_add_times_featured_to_request_for_comments.rb new file mode 100644 index 00000000..348292af --- /dev/null +++ b/db/migrate/20180202132034_add_times_featured_to_request_for_comments.rb @@ -0,0 +1,5 @@ +class AddTimesFeaturedToRequestForComments < ActiveRecord::Migration + def change + add_column :request_for_comments, :times_featured, :integer, default: 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index 23b7e3a0..dc2f5022 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180130172021) do +ActiveRecord::Schema.define(version: 20180202132034) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -281,6 +281,7 @@ ActiveRecord::Schema.define(version: 20180130172021) do t.integer "submission_id" t.text "thank_you_note" t.boolean "full_score_reached", default: false + t.integer "times_featured", default: 0 end create_table "searches", force: :cascade do |t|