Class: Oxidizer::ResourcesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Oxidizer::ResourcesController
show all
- Defined in:
- app/controllers/oxidizer/resources_controller.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.resource ⇒ Object
20
21
22
|
# File 'app/controllers/oxidizer/resources_controller.rb', line 20
def self.resource
raise NotImplementedError, "ResourcesController.resource must be an ActiveModel or ActiveRecord class"
end
|
Instance Method Details
#create ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'app/controllers/oxidizer/resources_controller.rb', line 39
def create
self.resource = resource_class.new(resource_params)
assign_attributes
authorize_resource
respond_to do |format|
if resource.save
flash_created_resource
format.html { redirect_to create_redirect_url, notice: create_notice }
format.json { render :show, status: :created, location: resource }
create_success_formats format
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: resource.errors, status: :unprocessable_entity }
end
end
end
|
#destroy ⇒ Object
74
75
76
77
78
79
80
81
|
# File 'app/controllers/oxidizer/resources_controller.rb', line 74
def destroy
resource.destroy
respond_to do |format|
format.html { redirect_to destroy_redirect_url, notice: destroy_notice }
format.json { head :no_content }
end
end
|
#edit ⇒ Object
36
37
|
# File 'app/controllers/oxidizer/resources_controller.rb', line 36
def edit
end
|
#index ⇒ Object
24
25
|
# File 'app/controllers/oxidizer/resources_controller.rb', line 24
def index
end
|
#new ⇒ Object
30
31
32
33
34
|
# File 'app/controllers/oxidizer/resources_controller.rb', line 30
def new
assign_new_resource
assign_attributes
authorize_resource
end
|
#show ⇒ Object
27
28
|
# File 'app/controllers/oxidizer/resources_controller.rb', line 27
def show
end
|
#update ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'app/controllers/oxidizer/resources_controller.rb', line 57
def update
resource.assign_attributes(resource_params)
assign_attributes
authorize_resource
respond_to do |format|
if resource.save
flash_updated_resource
format.html { redirect_to update_redirect_url, notice: update_notice }
format.json { render :show, status: :ok, location: resource }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: resource.errors, status: :unprocessable_entity }
end
end
end
|