Class: Wallaby::ResourcesController
Class Method Summary
collapse
Instance Method Summary
collapse
#status
#not_found, #unprocessable_entity
Instance Method Details
#create ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# File 'app/controllers/wallaby/resources_controller.rb', line 26
def create
authorize! :create, current_model_class
@resource, is_success = current_model_service.create params, current_ability
if is_success
redirect_to resources_index_path, notice: 'successfully created'
else
flash.now[:error] = 'failed to create'
render :new
end
end
|
#destroy ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'app/controllers/wallaby/resources_controller.rb', line 56
def destroy
authorize! :destroy, resource
if current_model_service.destroy resource, params
redirect_to resources_index_path, notice: 'successfully destroyed'
else
redirect_to resources_show_path, error: 'failed to destroy'
end
end
|
#edit ⇒ Object
41
42
43
|
# File 'app/controllers/wallaby/resources_controller.rb', line 41
def edit
authorize! :edit, resource
end
|
#index ⇒ Object
17
18
19
20
|
# File 'app/controllers/wallaby/resources_controller.rb', line 17
def index
authorize! :index, current_model_class
collection
end
|
#new ⇒ Object
22
23
24
|
# File 'app/controllers/wallaby/resources_controller.rb', line 22
def new
authorize! :new, new_resource
end
|
#show ⇒ Object
37
38
39
|
# File 'app/controllers/wallaby/resources_controller.rb', line 37
def show
authorize! :show, resource
end
|
#update ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'app/controllers/wallaby/resources_controller.rb', line 45
def update
authorize! :update, resource
@resource, is_success = current_model_service.update resource, params, current_ability
if is_success
redirect_to resources_show_path, notice: 'successfully updated'
else
flash.now[:error] = 'failed to update'
render :edit
end
end
|