Sha256: a7e2612b0f549485c0d2a2e05085e910fd314f173e10086efbdc05f37f546a20
Contents?: true
Size: 769 Bytes
Versions: 14
Compression:
Stored size: 769 Bytes
Contents
module Eventify extend ActiveSupport::Concern included do resource_class.state_machine.events.map(&:name).each do |event| define_method event do respond_to do |format| format.html do resource.assign_attributes(permitted_params[resource_instance_name]) if permitted_params[resource_instance_name] if resource.fire_state_event(event) redirect_to [current_namespace, current_parent, resource], notice: t('flash.success', action_name: resource_class.human_state_event_name(event).capitalize) else flash[:alert] = resource.errors.full_messages.join('<br>') render action: :show end end end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems