Sha256: c0b444f4371be4d4c258ccee5ae094e4144a576bf941c498540dfe431d58b0a1
Contents?: true
Size: 1.27 KB
Versions: 56
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true class Tramway::Admin::HasAndBelongsToManyRecordsController < ::Tramway::Admin::ApplicationController def create base_object = params[:model_class].constantize.find params[:object_id] form_class = params[:form].constantize record_form = form_class.new base_object sending_params = if params[params[:model_class].underscore].present? params[params[:model_class].underscore] else params[form_class.associated_as] end if record_form.submit sending_params redirect_to params[:redirect].present? ? params[:redirect] : record_path(base_object, model: base_object.class) else redirect_to params[:redirect].present? ? params[:redirect] : record_path(base_object, model: base_object.class) end end def destroy base_object = params[:model_class].constantize.find params[:object_id] record_form = params[:form].constantize.new base_object if record_form.submit params[:id] redirect_to params[:redirect].present? ? params[:redirect] : record_path(base_object, model: base_object.class) else redirect_to params[:redirect].present? ? params[:redirect] : record_path(base_object, model: base_object.class) end end end
Version data entries
56 entries across 56 versions & 1 rubygems