Class: Pbw::ItemContainersController
Instance Attribute Summary
#model_class
Instance Method Summary
collapse
#create, #destroy, #index, #model_for_read, #model_for_update, #model_id, #show, #update, #update_model_before_create, #update_model_before_update
#current_ability
Instance Method Details
#index_models ⇒ Object
25
26
27
28
|
# File 'app/controllers/pbw/item_containers_controller.rb', line 25
def index_models
authorize! :read, token_or_area_or_user
@models = token_or_area_or_user.item_containers
end
|
#model_for_create ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'app/controllers/pbw/item_containers_controller.rb', line 30
def model_for_create
authorize! :update, token_or_area_or_user
@model = model_class.new(params)
if token_or_area_or_user.ancestors.include?(Area)
@model.area = token_or_area_or_user
elsif token_or_area_or_user.ancestors.include?(Token)
@model.token = token_or_area_or_user
elsif token_or_area_or_user.ancestors.include?(User)
@model.user = token_or_area_or_user
end
update_model_before_create(@model)
end
|
#real_model_class ⇒ Object
7
8
9
|
# File 'app/controllers/pbw/item_containers_controller.rb', line 7
def real_model_class
self.model_class
end
|
#set_model_class ⇒ Object
3
4
5
|
# File 'app/controllers/pbw/item_containers_controller.rb', line 3
def set_model_class
self.model_class = ItemContainer
end
|
#token_or_area_or_user ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'app/controllers/pbw/item_containers_controller.rb', line 11
def token_or_area_or_user
return @token_or_area_or_user if defined?(@token_or_area_or_user) && @token_or_area_or_user
begin
unless params[:_type].blank?
klass = Kernel.get_const(params[:_type])
return @token_or_area_or_user = klass.find(params[:container_id])
else
return @token_or_area_or_user = current_user
end
rescue
nil
end
end
|