Answer the question
In order to leave comments, you need to log in
Rails 5.2 API mode. How to fix ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "active_storage_blobs" does not exist)?
The history of this issue is quite voluminous. Therefore, the beginning is here: Rails 5.2 API-mode. How to get rid of ActiveSuppor... I found out what it does
. InvalidSignature
Dispatched by people like me if the method verify
from MessageVerifier
thinks that the message being processed was not signed correctly or was not Base64 encoded. And don't ask me what it all means. I also found out the reasons for the appearance of this InvalidSignature: it appears when I send null
or even an empty string instead of a file. For the sake of experiment, I commented out extra attachments in the code:
class Testimonial < ApplicationRecord
# has_one_attached :userpic
has_one_attached :object_photo_1
# has_one_attached :object_photo_2
# has_one_attached :object_photo_3
validates :name, presence: true
validates :video, presence: true, if: Proc.new { |t| t.text.blank? }
validates :text, presence: true, if: Proc.new { |t| t.video.blank? }
end
Started POST "/admin/v1/testimonials" for ::1 at 2019-07-05 21:03:46 +0300
Processing by Admin::TestimonialsController#create as JSON
Parameters: {"name"=>"sdfasdf", "patronymic"=>"", "surname"=>"", "userpic"=>"", "company"=>"", "object_photo_1"=>#<ActionDispatch::Http::UploadedFile:0x00007f22f450f3c0 @tempfile=#<Tempfile:/tmp/RackMultipart20190705-10176-bw9ytk.jpg>, @original_filename="filename.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"object_photo_1\"; filename=\"filename.jpg\"\r\nContent-Type: image/jpeg\r\n">, "object_photo_2"=>"null", "object_photo_3"=>"null", "video"=>"", "text"=>"sadfasdf"}
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2
↳ /home/yart/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98
JwtBlacklist Exists (0.7ms) SELECT 1 AS one FROM "jwt_blacklists" WHERE "jwt_blacklists"."jti" = $1 LIMIT $2
↳ /home/yart/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.3/lib/active_record/log_subscriber.rb:98
Unpermitted parameter: :format
Completed 500 Internal Server Error in 6ms (ActiveRecord: 1.8ms)
ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "active_storage_blobs" does not exist
LINE 8: WHERE a.attrelid = '"active_storage_blobs"'::...
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
c.collname, col_description(a.attrelid, a.attnum) AS comment
FROM pg_attribute a
LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
LEFT JOIN pg_type t ON a.atttypid = t.oid
LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
WHERE a.attrelid = '"active_storage_blobs"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
):
app/controllers/admin/testimonials_controller.rb:23:in `create'
Answer the question
In order to leave comments, you need to log in
Active Storage uses two tables in your application's database named active_storage_blobs and active_storage_attachments. After creating a new application (or upgrading your application to Rails 5.2), run rails active_storage:install to generate a migration that creates these tables. Use rails db:migrate to run the migration.
Taken from your source.
Also, it's a lot of pain to wade through tons of lyrics, flashbacks and flashy humor to get to the heart of the matter.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question