我的控制器中有两个动作
def up_vote
lesson = Lesson.find(params[:id])
current_user.up_vote!(lesson)
flash[:message] = 'Thanks for voting!'
redirect_to lesson_path(lesson)
end
def down_vote
lesson = Lesson.find(params[:id])
current_user.down_vote!(lesson)
flash[:message] = 'Thanks for voting!'
redirect_to lesson_path(lesson)
end
我想知道什么是重构这个的好方法(记住 DRY)?我在网上读到我不应该试图滥用 before_filter。那我还能用什么?谢谢!