Add form to assign targets to a record

This commit is contained in:
Javi Martín
2020-11-25 12:02:03 +01:00
parent 11c3b3db13
commit f76279a4dd
10 changed files with 97 additions and 2 deletions

View File

@@ -1,14 +1,25 @@
class SDGManagement::RelationsController < SDGManagement::BaseController
before_action :load_record, only: [:edit, :update]
def index
@records = relatable_class.accessible_by(current_ability).order(:id).page(params[:page])
end
def edit
@record = relatable_class.find(params[:id])
end
def update
@record.sdg_target_list = params[@record.class.table_name.singularize][:sdg_target_list]
redirect_to action: :index
end
private
def load_record
@record = relatable_class.find(params[:id])
end
def relatable_class
params[:relatable_type].classify.constantize
end