Skip to content

Commit

Permalink
Add if/ese statement to create method to catch additional errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobyarborough committed Jan 17, 2024
1 parent 6702bd9 commit bfae7d7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/controllers/resources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ class ResourcesController < ApplicationController

def create
self.resource = current_organization.resources.new(resource_params(current_organization.id))

resource.save
logger.info "Created #{resource}"
redirect_to resource, notice: "The resource has been created"

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

def destroy
Expand Down

0 comments on commit bfae7d7

Please sign in to comment.