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

Version Path
comfortable_mexican_loveseat-0.1.1 app/controllers/concerns/eventify.rb
comfortable_mexican_loveseat-0.1.0 app/controllers/concerns/eventify.rb
comfortable_mexican_loveseat-0.0.23 app/controllers/concerns/eventify.rb
comfortable_mexican_loveseat-0.0.22 app/controllers/concerns/eventify.rb
comfortable_mexican_loveseat-0.0.21 app/controllers/concerns/eventify.rb
comfortable_mexican_loveseat-0.0.20 app/controllers/concerns/eventify.rb
comfortable_mexican_loveseat-0.0.19 app/controllers/concerns/eventify.rb
comfortable_mexican_loveseat-0.0.18 app/controllers/concerns/eventify.rb
comfortable_mexican_loveseat-0.0.17 app/controllers/concerns/eventify.rb
comfortable_mexican_loveseat-0.0.16 app/controllers/concerns/eventify.rb
comfortable_mexican_loveseat-0.0.15 app/controllers/concerns/eventify.rb
comfortable_mexican_loveseat-0.0.14 app/controllers/concerns/eventify.rb
comfortable_mexican_loveseat-0.0.13 app/controllers/concerns/eventify.rb
comfortable_mexican_loveseat-0.0.12 app/controllers/concerns/eventify.rb