Questions tagged [ruby-on-rails-5.2]

For issues specific to the version 5.2 of Rails. If your question applies to Ruby on Rails in general, use the tag [ruby-on-rails].

Ruby on Rails 5.2, "an open-source web framework that's optimized for programmer happiness and sustainable productivity." Rails 5.2 brings a bunch of new features and improvements over older Rails versions.

Major Features

  • Active Storage
  • Redis Cache Store
  • HTTP/2 Early Hints
  • Credentials

See Ruby on Rails 5.2 Release Notes for more information.

Resources

Related tags

538 questions
36
votes
8 answers

Rails: How to fix "Missing secret_key_base for 'production' environment"

I simply can't get past the message: Missing `secret_key_base` for 'production' environment, set this string with `rails credentials:edit` (ArgumentError) I have Rails 5.2.0, and ran EDITOR=vim rails credentials:edit and inside: production: …
Sylar
  • 8,631
  • 20
  • 72
  • 139
30
votes
3 answers

DEPRECATION WARNING: Dangerous query method: Random Record in ActiveRecord >= 5.2

So far, the "common" way to get a random record from the Database has been: # Postgress Model.order("RANDOM()").first # MySQL Model.order("RAND()").first But, when doing this in Rails 5.2, it shows the following Deprecation Warning: DEPRECATION…
29
votes
3 answers

Disable Active Storage in Rails 5.2

Upgrading Rails to 5.2, and I found out that I must commit the storage.yml into version control. I don't plan to use ActiveStorage. Is there a way to disable it?
lulalala
  • 15,996
  • 12
  • 101
  • 165
27
votes
7 answers

ActiveStorage File Attachment Validation

Is there a way to validate attachments with ActiveStorage? For example, if I want to validate the content type or the file size? Something like Paperclip's approach would be great! validates_attachment_content_type :logo, content_type:…
Tom Rossi
  • 10,170
  • 5
  • 55
  • 85
20
votes
6 answers

Rails: ActiveSupport::MessageEncryptor::InvalidMessage

Help me please, I've finished 11 chapters of the rails tutorial, deployed my app to heroku (locally it worked perfectly) and it crashing all time. I'm using rails 5.2.2 After execution of command $heroku run rails console I'm receiving…
user9409769
19
votes
1 answer

Use Rails 5.2 ActiveStorage to create and save pdf and later attach to email

I am afraid i am getting something completely wrong with the new active storage feature. What I want to do is to create an pdf ( I am using WickedPdf ) and attach it to a model. Here is the first issue, The only chance i figured out so far is to…
15
votes
3 answers

Rails active storage - Open/download link

A question on Active Storage: I just updated to rails 5.2 and I am trying to open the attached document which is saved as a blob. Currently, it's redirecting to root_path, any idea how can I open/download it instead? My code in Rails view is: <%=…
15
votes
3 answers

Separate secret_key_base in Rails 5.2?

I just upgraded from 5.1 to 5.2 and I'm quite confused about this 'better' methodology to storing secrets... Maybe I'm not understanding, but it seems like now development and production have been 'merged' into a SINGLE SECRET_KEY_BASE as well as…
Tallboy
  • 11,480
  • 11
  • 67
  • 151
14
votes
4 answers

How can I get url of my attachment stored in active storage in my rails controller

How can I get url of my has_one model attachment stored in active storage in my rails controller. So, that I would be able to send it as full link as api in json. So far, I have tried following methods but each of them are giving various…
13
votes
1 answer

How do you solve N+1 for ActiveStorage URLs?

How do you preload all the records with their URLs? This is what I am doing in my jbuilder to get the URLs: # views/users/index.json.jbuilder ... json.avatar_url user.avatar.attached? && rails_blob_url(user.avatar) ... Comment has_one…
Strawberry
  • 58,930
  • 53
  • 138
  • 190
13
votes
2 answers

Active Storage: Best practice to retain/cache uploaded file when form redisplays

When uploading files with Active Storage, when a file is finished uploading and the form gets redisplayed, for example when the validation for that form fails for some reason, the file is gone. Is there a way to cache or retain it between form…
cseelus
  • 1,021
  • 13
  • 25
12
votes
6 answers

Cannot load Rails.config.active_storage.service

I'm setting up a new rails 5.2 app utilising Active Storage and using AWS for the hosting of images in production. However, I'm having an issue with the app reading the credentials: 2018-07-06T08:11:52.625415+00:00 app[web.1]: ! Unable to load…
12
votes
5 answers

Rails 5.2 encrypted credentials not saving

When I do bin/rails credentials:edit my editor opens a file like credentials.yml.enc.1234 with default content. After I'm done editing, I hit save, and the console reads New credentials encrypted and saved. After I run bin/rails credentials:edit…
The Whiz of Oz
  • 6,125
  • 7
  • 43
  • 79
12
votes
4 answers

How to specify a prefix when uploading to S3 using activestorage's direct upload?

With a standard S3 configuration: AWS_ACCESS_KEY_ID: [AWS ID] AWS_BUCKET: [bucket name] AWS_REGION: [region] AWS_SECRET_ACCESS_KEY: [secret] I can upload a file to S3 (using direct upload) with this Rails 5.2…
11
votes
2 answers

Rails ActiveStorage attachment to existing S3 file

I'm building a PDF parser that fires off a Sidekiq worker to OCR parse data from a document stored in S3. After parsing, the data is stored in the Document model. How do I append the existing S3 bucket file to Document.attachment.attach in…
Shelby S
  • 330
  • 2
  • 17
1
2 3
35 36