用户留言增加登录判断,并且删除匿名用户留言数据

This commit is contained in:
sw 2015-09-06 17:06:05 +08:00
parent b771cc0fe1
commit 62c657a827
2 changed files with 23 additions and 4 deletions

View File

@ -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

View File

@ -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