From 62c657a827dc37cfc06f204ea83c69a8587128f9 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sun, 6 Sep 2015 17:06:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=95=99=E8=A8=80=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=99=BB=E5=BD=95=E5=88=A4=E6=96=AD=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E4=B8=94=E5=88=A0=E9=99=A4=E5=8C=BF=E5=90=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=95=99=E8=A8=80=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/words_controller.rb | 12 ++++++++---- .../20150906090419_delete_anonymous_feedback.rb | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20150906090419_delete_anonymous_feedback.rb diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 5158a99c4..77304c1b1 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -202,11 +202,15 @@ class WordsController < ApplicationController #给用户留言 def leave_user_message - @user = User.find(params[:id]) - if params[:new_form][:user_message].size>0 && User.current.logged? && @user - @user.add_jour(User.current, params[:new_form][:user_message]) + if User.current.logged? + @user = User.find(params[:id]) + if params[:new_form][:user_message].size>0 && User.current.logged? && @user + @user.add_jour(User.current, params[:new_form][:user_message]) + end + redirect_to feedback_path(@user) + else + render_403 end - redirect_to feedback_path(@user) end # add by nwb diff --git a/db/migrate/20150906090419_delete_anonymous_feedback.rb b/db/migrate/20150906090419_delete_anonymous_feedback.rb new file mode 100644 index 000000000..a96d6b30d --- /dev/null +++ b/db/migrate/20150906090419_delete_anonymous_feedback.rb @@ -0,0 +1,15 @@ +class DeleteAnonymousFeedback < ActiveRecord::Migration + def up + jour_count = JournalsForMessage.all.count / 30 + 2 + transaction do + for i in 1 ... jour_count do i + JournalsForMessage.page(i).per(30).each do |jour| + jour.destroy if jour.user_id == 2 + end + end + end + end + + def down + end +end