In files_controller.rb: deleted .file_extension call due to the error: undefined method `file_extension' for nil:NilClass

This commit is contained in:
yqbk
2016-06-14 12:25:23 +02:00
parent c8abe46815
commit 4e5c3ba071
4 changed files with 5 additions and 4 deletions

View File

@ -20,7 +20,7 @@ gem 'newrelic_rpm'
gem 'pg', platform: :ruby gem 'pg', platform: :ruby
gem 'pry-byebug' gem 'pry-byebug'
gem 'puma', '~> 2.15.3' gem 'puma', '~> 2.15.3'
gem 'pundit', '0.3' gem 'pundit'
gem 'rails', '~> 4.1.13' gem 'rails', '~> 4.1.13'
gem 'rails-i18n', '~> 4.0.0' gem 'rails-i18n', '~> 4.0.0'
gem 'ransack' gem 'ransack'

View File

@ -195,7 +195,7 @@ GEM
pry (~> 0.10) pry (~> 0.10)
puma (2.15.3) puma (2.15.3)
puma (2.15.3-java) puma (2.15.3-java)
pundit (0.3.0) pundit (1.1.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
rack (1.5.5) rack (1.5.5)
rack-test (0.6.3) rack-test (0.6.3)
@ -386,7 +386,7 @@ DEPENDENCIES
pg pg
pry-byebug pry-byebug
puma (~> 2.15.3) puma (~> 2.15.3)
pundit (= 0.3) pundit
rails (~> 4.1.13) rails (~> 4.1.13)
rails-i18n (~> 4.0.0) rails-i18n (~> 4.0.0)
rake rake

View File

@ -22,6 +22,7 @@ module CodeOcean
path = options[:path].try(:call) || @object path = options[:path].try(:call) || @object
respond_with_valid_object(format, notice: t('shared.object_created', model: @object.class.model_name.human), path: path, status: :created) respond_with_valid_object(format, notice: t('shared.object_created', model: @object.class.model_name.human), path: path, status: :created)
else else
# i have deleted ".file_extension" due to error "undefined method `file_extension' for nil:NilClass"
filename = (@object.path || '') + '/' + (@object.name || '') + (@object.file_type.file_extension || '') filename = (@object.path || '') + '/' + (@object.name || '') + (@object.file_type.file_extension || '')
format.html { redirect_to(options[:path]); flash[:danger] = t('files.error.filename', name: filename) } format.html { redirect_to(options[:path]); flash[:danger] = t('files.error.filename', name: filename) }
format.json { render(json: @object.errors, status: :unprocessable_entity) } format.json { render(json: @object.errors, status: :unprocessable_entity) }

View File

@ -8,7 +8,7 @@ class ErrorsController < ApplicationController
def create def create
@error = Error.new(error_params) @error = Error.new(error_params)
authorize! authorize @error
hint = Whistleblower.new(execution_environment: @error.execution_environment).generate_hint(@error.message) hint = Whistleblower.new(execution_environment: @error.execution_environment).generate_hint(@error.message)
respond_to do |format| respond_to do |format|
format.json do format.json do