Я недавно переключился с скрепки на activestorage.Как правило, это было безболезненное преобразование, за исключением того, что при создании новых пользователей в моем приложении я получаю эту ошибку:
Часть журнала серверас указанием ошибки:
(0.6ms) BEGIN
User Exists (5.0ms) SELECT 1 AS one FROM "users" WHERE LOWER("users"."email") = LOWER($1) LIMIT $2 [["email", "billz@billz.com"], ["LIMIT", 1]]
User Create (7.9ms) INSERT INTO "users" ("name", "email", "created_at", "updated_at", "password_digest", "occupation", "location", "twitter", "linkedin", "github", "first_name", "last_name") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12) RETURNING "id" [["name", "billzboi"], ["email", "billz@billz.com"], ["created_at", "2018-11-18 01:24:48.907102"], ["updated_at", "2018-11-18 01:24:48.907102"], ["password_digest", "$2a$10$kHluW818Ro8S8po6VrGke.LjR2qUYvBMg/4v/YCeV1ap3E1ybGHWC"], ["occupation", ""], ["location", ""], ["twitter", ""], ["linkedin", ""], ["github", ""], ["first_name", "Billy"], ["last_name", "billz"]]
ActiveStorage::Attachment Create (1.8ms) INSERT INTO "active_storage_attachments" ("name", "record_type", "record_id", "blob_id", "created_at") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["name", "photo"], ["record_type", "User"], ["record_id", 22], ["blob_id", 7], ["created_at", "2018-11-18 01:24:48.918588"]]
(0.6ms) ROLLBACK
Completed 500 Internal Server Error in 479ms (ActiveRecord: 76.6ms)
NoMethodError (undefined method `photo?' for #<User:0x007f9c04284770>
Did you mean? photo
photo=):
app/controllers/users_controller.rb:31:in `create'
ActiveStorage::Blob Load (6.0ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 LIMIT $2 [["id", 6], ["LIMIT", 1]]
[ActiveJob] [ActiveStorage::PurgeJob] [14eed28d-12ad-46f8-aee1-21b315e6268b] Performing ActiveStorage::PurgeJob (Job ID: 14eed28d-12ad-46f8-aee1-21b315e6268b) from Async(default) with arguments: #<GlobalID:0x007f9c05474278 @uri=#<URI::GID gid://spitball/ActiveStorage::Blob/6>>
ActiveStorage::Blob Load (28.9ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 LIMIT $2 [["id", 6], ["LIMIT", 1]]
[ActiveJob] [ActiveStorage::AnalyzeJob] [7ebac64f-92eb-435e-9431-17dcd3c1465a] Performing ActiveStorage::AnalyzeJob (Job ID: 7ebac64f-92eb-435e-9431-17dcd3c1465a) from Async(default) with arguments: #<GlobalID:0x007f9c009a7178 @uri=#<URI::GID gid://spitball/ActiveStorage::Blob/6>>
[ActiveJob] [ActiveStorage::PurgeJob] [14eed28d-12ad-46f8-aee1-21b315e6268b] Disk Storage (0.2ms) Deleted file from key: pz1QmK2yL4s6YAfqoZein1nv
[ActiveJob] [ActiveStorage::PurgeJob] [14eed28d-12ad-46f8-aee1-21b315e6268b] Disk Storage (0.2ms) Deleted files by key prefix: variants/pz1QmK2yL4s6YAfqoZein1nv/
[ActiveJob] [ActiveStorage::PurgeJob] [14eed28d-12ad-46f8-aee1-21b315e6268b] (2.0ms) BEGIN
[ActiveJob] [ActiveStorage::AnalyzeJob] [7ebac64f-92eb-435e-9431-17dcd3c1465a] Error performing ActiveStorage::AnalyzeJob (Job ID: 7ebac64f-92eb-435e-9431-17dcd3c1465a) from Async(default) in 963.11ms: Errno::ENOENT (No such file or directory @ rb_sysopen - /Users/iThompkins/Desktop/Side Hustle/Spitball/Spitball_app/storage/pz/1Q/pz1QmK2yL4s6YAfqoZein1nv):
/Users/iThompkins/.rvm/gems/ruby-2.4.1/gems/activestorage-5.2.0/lib/active_storage/service/disk_service.rb:28:in `initialize'
/Users/iThompkins/.rvm/gems/ruby-2.4.1/gems/activestorage-5.2.0/lib/active_storage/service/disk_service.rb:28:in `open'
/Users/iThompkins/.rvm/gems/ruby-2.4.1/gems/activestorage-5.2.0/lib/active_storage/service/disk_service.rb:28:in `block in download'
/Users/iThompkins/.rvm/gems/ruby-2.4.1/gems/activesupport-5.2.0/lib/active_support/notifications.rb:170:in `instrument'
И вызываемое действие
def create
@user = User.new(user_params)
@user.photo.attach(params[:user][:photo])
if @user.save
UserMailer.welcome_email(@user).deliver_now
log_in @user
flash[:success] = "Welcome to Our Beta!"
redirect_to @user
else
render 'new'
end
end
Модель пользователя использует метод 'has_one_attached' из активного хранилища и принимает в качестве параметра ': photo'.Я не могу сказать, где '.photo?'вызывается, поэтому я не могу устранить ошибку.