Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @resource.aasm.events.each do |event|
- member_action event.name, method: :post do
- resource.send(event) if resource.aasm.may_fire_event?(event.name)
- end
- action_item event, only: :show, if: -> { resource.aasm.may_fire_event?(event.name) } do
- link_to event.name.capitalize, action: event.name, controller: :ties, method: :post
- end
- batch_action event.name do |ids|
- klass = controller_name.classify.constantize
- count = 0
- klass.find(ids).each do |resource|
- next unless resource.aasm.may_fire_event?(event.name)
- resource.send("#{event.name}!".to_sym)
- count += 0
- end
- flash_message = "Succeeded with #{event.name} for #{view_context.pluralize count, controller_name}."
- flash_type = :notice
- if count<ids.count
- flash_message += " WARNING: Could not #{event.name} #{view_context.pluralize ids. WARNING-count, controller_name}."
- flash_type = :alert
- end
- redirect_to collection_path, flash_type => flash_message
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement