From 21b4bd3949aeee59f7c95b045e64762d8bf968dd Mon Sep 17 00:00:00 2001 From: YOSHIDA Hiroki Date: Mon, 13 Jan 2014 22:15:39 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=BE=E3=81=A8=E3=82=81=E7=B7=A8=E9=9B=86:?= =?UTF-8?q?=20=E3=81=BE=E3=81=A8=E3=82=81=E7=B7=A8=E9=9B=86=E6=99=82?= =?UTF-8?q?=E3=81=AB=E6=9B=B4=E6=96=B0=E6=97=A5=E6=99=82=E3=81=8C=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/matomes_controller.rb | 2 +- app/models/concerns/active_record_extension.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/matomes_controller.rb b/app/controllers/matomes_controller.rb index 054be0e..0ed237f 100644 --- a/app/controllers/matomes_controller.rb +++ b/app/controllers/matomes_controller.rb @@ -82,7 +82,7 @@ def update @matome = Matome.find(params[:id]) @matome.clip_ids = Clip.where(user_id: current_user.id, id: clip_ids).pluck(:id) - if @matome.update_attributes(params[:matome]) + if @matome.force_update_attributes(params[:matome]) update_tags_for(@matome, tag_names) redirect_to @matome, notice: "「#{@matome.title}」まとめを更新しました" else diff --git a/app/models/concerns/active_record_extension.rb b/app/models/concerns/active_record_extension.rb index 892205c..c87635a 100644 --- a/app/models/concerns/active_record_extension.rb +++ b/app/models/concerns/active_record_extension.rb @@ -1,6 +1,15 @@ module ActiveRecordExtension extend ActiveSupport::Concern + included do + def force_update_attributes(*args) + self.partial_updates = false + result = self.update_attributes(*args) + self.partial_updates = true + result + end + end + module ClassMethods def without_record_timestamps self.record_timestamps = false