Skip to content

Instantly share code, notes, and snippets.

@hallgren
Created December 1, 2015 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hallgren/6d4fd0acd937e2409599 to your computer and use it in GitHub Desktop.
Save hallgren/6d4fd0acd937e2409599 to your computer and use it in GitHub Desktop.
# yaks mapper
form :make_admin, if: -> { !object.admin? && !object.my_self? } do
action '/api/admin/users/{user_guid}'
method 'POST'
media_type 'application/json'
hidden :action, value: -> { 'make_admin' }
end
# controller
post '/api/admin/user/:user_guid' do
user_guid = params[:user_guid]
case params[:action]
when 'make_admin'
ToolboxAdminBc::ApplicationServices::ToolboxUserSettingsService.make_admin user_guid: user_guid
when 'revoke_admin'
ToolboxAdminBc::ApplicationServices::ToolboxUserSettingsService.revoke_admin user_guid: user_guid
redirect "/api/admin/users/#{user_guid}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment