Sha256: c97851ed23d9a2e1d4d2fb4ded3b37eba4d4f330614fefca176f766a62431090
Contents?: true
Size: 1.39 KB
Versions: 10
Compression:
Stored size: 1.39 KB
Contents
class Oxen::PrintersController < AbstractResourcesController def update authorize resource flash[:notice] = t('.success.updated', resource: resource_class.to_s ) if resource.update_attributes(resource_params) && update_parenthood respond_with resource, location: "/admin/accounts/#{resource.account.id}" rescue Exception => e scoop_from_error e end private def set_fab_button_options opt = { items: {}} case params[:action] when 'edit','update'; opt[:items].merge! list: { ajax: 'get', icon: 'list', class: 'blue', url: "/admin/accounts/#{resource.account.id}" } when 'show'; opt[:items].merge! list: { ajax: 'get', icon: 'list', class: 'blue', url: "/admin/accounts/#{resource.account.id}" } when 'index'; opt[:items].merge! list: { ajax: 'get', icon: 'list', class: 'blue', url: "/admin/accounts/#{resource.account.id}" } end @fab_button_options = opt end # Never trust parameters from the scary internet, only allow the white list through. # "printer"=>{"name"=>"Label", "cups_printer"=>"havehuset_label", "command"=>"lp %2 %3", "paper"=>"A4", "active"=>"1"}} def resource_params params[:printer][:account_id] = current_user.admin? ? params[:parent_id] : current_user.account.id params.require(:printer).permit(:account_id, :active, :name, :cups_printer, :command, :paper) end end
Version data entries
10 entries across 10 versions & 1 rubygems