Adapt backend to enable flagging/unflagging investments
This commit is contained in:
@@ -3,18 +3,32 @@ module FlagActions
|
||||
|
||||
def flag
|
||||
Flag.flag(current_user, flaggable)
|
||||
respond_with flaggable, template: "#{controller_name}/_refresh_flag_actions"
|
||||
|
||||
if controller_name == 'investments'
|
||||
respond_with flaggable, template: "budgets/#{controller_name}/_refresh_flag_actions"
|
||||
else
|
||||
respond_with flaggable, template: "#{controller_name}/_refresh_flag_actions"
|
||||
end
|
||||
end
|
||||
|
||||
def unflag
|
||||
Flag.unflag(current_user, flaggable)
|
||||
respond_with flaggable, template: "#{controller_name}/_refresh_flag_actions"
|
||||
|
||||
if controller_name == 'investments'
|
||||
respond_with flaggable, template: "budgets/#{controller_name}/_refresh_flag_actions"
|
||||
else
|
||||
respond_with flaggable, template: "#{controller_name}/_refresh_flag_actions"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def flaggable
|
||||
instance_variable_get("@#{resource_model.to_s.downcase}")
|
||||
if resource_model.to_s == 'Budget::Investment'
|
||||
instance_variable_get("@investment")
|
||||
else
|
||||
instance_variable_get("@#{resource_model.to_s.downcase}")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user