refactors debate and proposal flag actions
This commit is contained in:
20
app/controllers/concerns/flag_actions.rb
Normal file
20
app/controllers/concerns/flag_actions.rb
Normal 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
|
||||
Reference in New Issue
Block a user