app/controllers/concerns/maquina/update.rb in maquina-0.2.2 vs app/controllers/concerns/maquina/update.rb in maquina-0.2.3
- old
+ new
@@ -6,21 +6,22 @@
included do
def update(&block)
@resource ||= begin
scope = resource_class
- # scope = scope.where(organization)
- # TODO: Implement filtering by organization
+ scope = authorized_scope(scope) if policy_class.present?
+
resource = scope.find_by!(find_by_param => params[:id])
authorize! resource, with: policy_class if policy_class.present?
resource
end
saved = @resource.update(resource_secure_params)
status = saved ? :accepted : :unprocessable_entity
+ Rails.logger.debug "UPDATE validation: #{@resource.errors.inspect}" if status == :unprocessable_entity
response.status = status
set_flash_message(status)
dual_action_response(@resource, &block)
end