refactors debate and proposal flag actions

This commit is contained in:
rgarcia
2015-09-28 16:33:23 +02:00
parent e7d1ae63d6
commit 6426bd3a29
3 changed files with 24 additions and 20 deletions

View File

@@ -0,0 +1,20 @@
module FlagActions
extend ActiveSupport::Concern
def flag
Flag.flag(current_user, flagable)
respond_with flagable, template: "#{controller_name}/_refresh_flag_actions"
end
def unflag
Flag.unflag(current_user, flagable)
respond_with flagable, template: "#{controller_name}/_refresh_flag_actions"
end
private
def flagable
instance_variable_get("@#{controller_name.singularize}")
end
end