This is for the readme :
-
To reduce the coding work when you modify your state machine,
you can ignore the routes.rb file !
you can code your route as :
map.resources :customers, :member => {}.merge(Customer.aasm_events.inject({}) {|acc, v| acc[v.first] = :put; acc})
and rails insert your routes for you ! To add your special
action insert it between the first {] before .merge .
-
To display a action bar you only have to create a partial in
this case, named action :
In the view insert :
<%= render :partial => "action", :object =>@customer %>
create _action.erb partial :
<% action.aasm_events_for_current_state.each do |state| -%>
<%= link_to(t(".link_#{state.to_s}"),eval("#{state.to_s}_#{action.class.to_s.underscore}_path(action)"), :method => :put)%> |
<% end -%>
Only the allowed actions are displayed This last code is adapted
from a code found in a forum, but I don't remember the URL. All
credits are going to this first contributer.
Hope this can help any other rail coder.
regards Serge