Class: AbstractResourcesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/abstract_resources_controller.rb

Constant Summary collapse

PRINTSUCCESS =
1
NOQUEUE =
-1
NOUSER =
-2
PRINTRECERROR =
-3
PRINTCMDERROR =
-4
PRINTLISTERROR =
-5
PRINTEXCEPTION =
-99

Instance Method Summary collapse



106
107
108
109
110
111
112
113
114
# File 'app/controllers/abstract_resources_controller.rb', line 106

def set_parents
  unless (resource_class.respond_to?( 'arraying') && resource? )
    @parents = []
  else
    @parents = resource_class.arraying({ order: 'name'}, resource.possible_parents)
  end
rescue Exception => e
  scoop_from_error e
end

#set_resource ⇒ Object



226
227
228
229
# File 'app/controllers/abstract_resources_controller.rb', line 226

def set_resource
  parent
  resource
end

#set_resources ⇒ Object



231
232
233
# File 'app/controllers/abstract_resources_controller.rb', line 231

def set_resources
  resources
end

#show ⇒ Object



116
117
118
119
120
121
# File 'app/controllers/abstract_resources_controller.rb', line 116

def show
  authorize resource
  respond_with resource
rescue Exception => e
  scoop_from_error e
end

#update ⇒ Object



195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'app/controllers/abstract_resources_controller.rb', line 195

def update
  authorize resource
  respond_with(resource, location: redirect_after_update) do |format|
    if resource.update_attributes(resource_params) && update_parenthood
      flash[:notice] = t('.success.updated', resource: resource_class.to_s )
    else
      format.html { render action: :edit, status: :unprocessable_entity }
      format.js { render action: :edit, status: :unprocessable_entity }
    end
  end
rescue Exception => e
  scoop_from_error e
end