Low commit activity in last 3 years
No release in over a year
Custom Administrate Field for AASM gem.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

 Project Readme

Administrate::Field::Aasm

Gem Version

Custom Administrate Field for AASM gem.

DEMO

Try the demo

Installation

Add this line to your application's Gemfile:

gem 'administrate-field-aasm'

And then execute:

$ bundle

Add to your dashboard:

ATTRIBUTE_TYPES = [
  state: Field::Aasm
]

SHOW_PAGE_ATTRIBUTES = %i[
  ...
  state
  ...
]

Add to your routes.rb

resources :orders do
  member do
    put '/:event', to: 'orders#transit_state'
  end
end

Add to your controller

def transit_state
  if requested_resource.try("may_#{params[:event]}?".to_sym)
    requested_resource.try(params[:event].to_sym)
    requested_resource.save
    redirect_to admin_order_path(requested_resource), notice: "#{params[:event].humanize} successfully."
  else
    redirect_to admin_order_path(requested_resource), alert: "#{params[:event].humanize} fail."
  end
end

License

The gem is available as open source under the terms of the MIT License.