Last active
August 29, 2015 14:27
-
-
Save passalini/1e6a7f356f3ad1b88173 to your computer and use it in GitHub Desktop.
RailsAdmin aasm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def change_state | |
object = Object.find(params[:object_id]) | |
object.send(params[:event] + '!') | |
redirect_to params[:redirect_to] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
edit do | |
configure :change_aasm_state do | |
pretty_value do | |
links = "" | |
object = bindings[:object] | |
view = bindings[:view] | |
events = object.aasm.events.map(&:name) | |
events.each do |event| | |
label = I18n.t event, scope: [:activerecord, :attributes, :object, :aasm_event] | |
links += view.link_to(label, view.main_app.object_change_state_path(object, event: event, | |
redirect_to: view.rails_admin.edit_path(model_name: :object, id: object.id)), | |
class: 'btn btn-default', method: :put) | |
end | |
links.html_safe | |
end | |
read_only true | |
end | |
fields :change_aasm_state | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment