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

540 questions
14
votes
2 answers

Rails environment variables vs Rails 5.2 credentials

I just wanted to know what the specific differentiation is between environment variables ENV[SOME_VARIABLE] vs. Rails 5.2 credentials Rails.application.credentials.some_variable When should I use one vs. the other? Did the credentials replace the…
stcho
  • 1,909
  • 3
  • 28
  • 45
14
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
  • 400
  • 4
  • 17
14
votes
7 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,763
  • 9
  • 48
  • 85
13
votes
4 answers

After updating ruby to 2.7.1 rspec tests throws error `Bundler::GemfileError for status code 4 but Bundler::GemfileError is already registered`

using Rails 5.2.4.3 Mac OSX Catalina 10.15.6 After updating ruby to 2.7.1 (via rvm) ran rspec spec and received error: Trying to register Bundler::GemfileError for status code 4 but Bundler::GemfileError is already registered #…
ea0723
  • 805
  • 11
  • 25
13
votes
1 answer

Dangerous query method deprecation warning on Rails 5.2.3

I am in the process of upgrading my Rails app to 5.2.3 I am using the following code in my app. MyModel.order('LOWER(name) ASC') It raises the following deprecation warning: DEPRECATION WARNING: Dangerous query method (method whose arguments are…
user11350468
  • 1,357
  • 1
  • 6
  • 22
13
votes
5 answers

Difference between update and update_attributes

In Rails 5, what is the difference between update and update_attributes methods. I'm seeing the following results for both the methods Returns true/false Checking for active record validation Call backs are triggered and also regarding update…
Sam
  • 5,040
  • 12
  • 43
  • 95
12
votes
3 answers

Remove all data from Active Storage?

I would like to know how can I delete all data from Active Storage or even resetting Active Storage? There is any way to do that? Thank you in advance! NOTE: I'm using Rails 5.2
Proz1g
  • 1,177
  • 4
  • 16
  • 36
12
votes
4 answers

Rails 5.2 credentials + asset precompile

I have a continuous integration which takes rails app and package it as a docker image. As one of the steps of this packaging process, I want to do asset precompilation. I was doing this on Rails 5.1. I had to provide some dummy SECRET_KEY_BASE to…
Victor Ronin
  • 22,758
  • 18
  • 92
  • 184
12
votes
6 answers

Rails Console error after upgrading to Ubuntu 18.04

After upgrading from ubuntu 16.04 to ubuntu 18.04 I am receiving the following error when running rails console from the root directory of rails project. Only the console seems to be affected, I am able to start the puma server without…
James
  • 123
  • 1
  • 6
11
votes
2 answers

How does "config/initializers/new_framework_defaults_5_2.rb" work?

Specifically... I don't understand how in a new Rails 5.2 app, if you enter the console and check Rails.application.config.action_controller.default_protect_from_forgery it'll return true ...but an upgraded Rails 5.2 app, if you enter the console…
James Chevalier
  • 10,604
  • 5
  • 48
  • 74
11
votes
1 answer

ActiveStorage get dirty object stating if an image as changed

I would like to know if an image has changed on an ActiveRecord model object so I can perform other functions but don't see anything available to know this. I.E. object.image.changed? or object.image_changed? or object.changed?
John Pollard
  • 3,729
  • 3
  • 24
  • 50
10
votes
2 answers

Append secrets to credentials.yml.enc programmatically

Is there a way to programmatically add secrets to config/credentials.yml.enc in Rails 5.2? Pushing the credentials.yml.enc to the repository for internal use may be fine, but as soon as the app is used by other people, they require different secrets…
Klumbe
  • 370
  • 2
  • 12
10
votes
3 answers

Cannot edit rails credentials Rails 5.2

I am working on a Rails 5.2 app and I have installed and setup active_storage, however, I can't seem to edit or show the rails credentials. Here is an output of the error ben@ben-VirtualBox:~/Desktop/benbagley$ EDITOR="atom --wait" rails…
user8331511
9
votes
1 answer

Use a single form_with to create and edit nested resources in Rails

Background Inside of my application, a series is composed of many books. A series' Show page allows a user to see all the books in a series and to add a new book to the series using a form. Every book listed on the Show page has a link to an Edit…
8
votes
3 answers

Getting filename before saving in ActiveStorage - Rails 5.2.1

I am trying to get the name of the file uploaded by a user before ActiveStorage goes on to save it. The form is generated using form_with and is shown below: <%= form_with model: upload do |form| %>
<%= form.file_field :files,…
troy34
  • 335
  • 1
  • 4
  • 10
1
2
3
35 36