用户留言增加登录判断,并且删除匿名用户留言数据
This commit is contained in:
parent
b771cc0fe1
commit
62c657a827
|
@ -202,11 +202,15 @@ class WordsController < ApplicationController
|
|||
|
||||
#给用户留言
|
||||
def leave_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
|
||||
end
|
||||
|
||||
# add by nwb
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue