Class: ResourcesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ResourcesController
- Includes:
- PermittedParameters
- Defined in:
- app/controllers/resources_controller.rb
Overview
Handles CRUD actions for Resource objects
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/resources_controller.rb', line 29 def create self.resource = current_organization.resources.new(resource_params) if resource.save logger.info "Created #{resource}" redirect_to resource, notice: 'The resource has been created' else logger.warn "Unable to create resource due to '#{resource.error_sentence}'" render :new end end |
#destroy ⇒ Object
51 52 53 54 |
# File 'app/controllers/resources_controller.rb', line 51 def destroy resource.destroy redirect_to organization_resources_url(current_organization), notice: 'Resource was successfully destroyed.' end |
#edit ⇒ Object
26 27 |
# File 'app/controllers/resources_controller.rb', line 26 def edit end |
#index ⇒ Object
13 14 |
# File 'app/controllers/resources_controller.rb', line 13 def index end |
#new ⇒ Object
19 20 21 22 23 24 |
# File 'app/controllers/resources_controller.rb', line 19 def new self.resource = current_organization.resources.new( title: '', resource_group: current_organization.resource_groups.default.first ) end |
#show ⇒ Object
16 17 |
# File 'app/controllers/resources_controller.rb', line 16 def show end |
#update ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/resources_controller.rb', line 41 def update if resource.update(resource_params) logger.info "Updated #{resource}" redirect_to resource, notice: 'The resource has been updated' else logger.warn "Unable to update resource due to '#{resource.error_sentence}'" render :edit end end |