В настоящее время у меня не проходит тест, когда я пытаюсь вызвать valid?
или headshot_image
на моем Player
объекте. Я не уверен, куда идти с этим после просмотра следа. Кто-нибудь может указать, что я, вероятно, делаю неправильно? Я могу вызвать любой атрибут на объекте игрока, и он реагирует соответственно, но для valid?
и headshot_image
я получаю ошибку.
Player.rb
class Player < ApplicationRecord
mount_uploader :headshot_image, PlayerHeadshotUploader
end
PlayerHeadshotUploader
class PlayerHeadshotUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}"
end
def default_url
"/uploads/player/no-profile-pic.jpg"
end
version :thumb do
process :resize_to_fit => [50, 50]
end
version :thumb do
process :resize_to_fit => [50, 50]
end
def extension_white_list
%w(jpg jpeg gif png)
end
def filename
"#{secure_token}.#{file.extension}" if original_filename
end
protected
def secure_token
var = :"@#{mounted_as}_secure_token"
model.instance_variable_get(var) or model.instance_variable_set(var, SecureRandom.uuid)
end
end
Ошибка и трассировка
(byebug) @player.headshot_image
*** ArgumentError Exception: wrong number of arguments (given 2, expected 0)
nil
(byebug) begin\; @player.headshot_image\; rescue Exception => e\; puts e.backtrace end
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/carrierwave-1.2.3/lib/carrierwave/mount.rb:448:in `initialize'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/carrierwave-1.2.3/lib/carrierwave/mount.rb:448:in `new'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/carrierwave-1.2.3/lib/carrierwave/mount.rb:448:in `_mounter'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/carrierwave-1.2.3/lib/carrierwave/mount.rb:142:in `headshot_image'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/carrierwave-1.2.3/lib/carrierwave/mount.rb:366:in `headshot_image'
(byebug):1:in `block in <class:PlayerTest>'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib/byebug/helpers/eval.rb:61:in `eval'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib/byebug/helpers/eval.rb:61:in `safe_eval'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib/byebug/helpers/eval.rb:55:in `warning_eval'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib/byebug/helpers/eval.rb:31:in `block in multiple_thread_eval'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib/byebug/helpers/eval.rb:94:in `allowing_other_threads'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib/byebug/helpers/eval.rb:31:in `multiple_thread_eval'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib/byebug/processors/command_processor.rb:163:in `block in run_cmd'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib/byebug/processors/command_processor.rb:168:in `safely'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib/byebug/processors/command_processor.rb:159:in `run_cmd'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib/byebug/processors/command_processor.rb:133:in `repl'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib/byebug/processors/command_processor.rb:97:in `process_commands'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib/byebug/processors/command_processor.rb:55:in `at_line'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/byebug-10.0.2/lib/byebug/context.rb:98:in `at_line'
/mnt/c/Users/mcdonaldd/Documents/Rails Projects/bane/test/models/player_test.rb:21:in `block in <class:PlayerTest>'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest/test.rb:98:in `block (3 levels) in run'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest/test.rb:195:in `capture_exceptions'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest/test.rb:95:in `block (2 levels) in run'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest.rb:265:in `time_it'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest/test.rb:94:in `block in run'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest.rb:360:in `on_signal'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest/test.rb:211:in `with_info_handler'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest/test.rb:93:in `run'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest.rb:960:in `run_one_method'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest.rb:334:in `run_one_method'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest.rb:321:in `block (2 levels) in run'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest.rb:320:in `each'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest.rb:320:in `block in run'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest.rb:360:in `on_signal'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest.rb:347:in `with_info_handler'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest.rb:319:in `run'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/railties-5.1.6/lib/rails/test_unit/line_filtering.rb:9:in `run'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest.rb:159:in `block in __run'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest.rb:159:in `map'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest.rb:159:in `__run'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest.rb:136:in `run'
/home/daveomcd/.rvm/gems/ruby-2.5.1/gems/minitest-5.11.3/lib/minitest.rb:63:in `block in autorun'
nil
Обновление добавления player_test.rb по запросу
require 'test_helper'
class PlayerTest < ActiveSupport::TestCase
setup do
@player = players(:one)
end
test "first_name is present" do
@player.first_name = nil
assert_not @player.save
end
end