Questions tagged [ruby-on-rails-6]

Ruby on Rails 6 is the latest version of Ruby on Rails, "an open-source web framework that's optimized for programmer happiness and sustainable productivity."

2084 questions
6
votes
2 answers

Bootstrap JS functions not loading in Rails 6/Webpacker

Climbing the learning curve with Webpacker and Rails 6. I've installed Boostrap 4 using Yarn and Webpacker. When I try play with Bootstrap components in a browser's JS console then I get: TypeError: $.fn.button is undefined. If I remove the Yarn…
Gazza
  • 3,051
  • 1
  • 20
  • 22
6
votes
2 answers

Using ERB in Markdown with Redcarpet

I'm trying to get Markdown to play nicely with .erb. I'd like to use high_voltage to render markdown pages (or normal .html.erb files with markdown partials) that are parsed with Redcarpet and am struggling to get it to all work together. At the…
Rich
  • 590
  • 7
  • 20
6
votes
1 answer

How to access custom javascript functions via browser-console in Rails 6

For the sake of debugging the javascript-part of a Rails 6 (version 6.0.0.rc1) web application I want to use my custom javascript functions also in the Chrome console (aka. Inspect). Back when I used just static HTML files to build a website (as…
TheCodeBat
  • 61
  • 2
6
votes
1 answer

How do easily filter CSV data in Ruby

I am dealing with a CSV file(approx 500 lines). Is there a way to select data from this file with filters. I know I can do this in ruby by parsing the csv and using select/find methods But I am looking for a simpler syntax. I don't want to write…
Rahul
  • 321
  • 2
  • 14
6
votes
1 answer

How to pass extra parameter in rails form_for

How I can get redirect_id from this form? <%= form_for(@category) do |f| %> <%= hidden_field_tag :redirect_id, :value=>5 %> <%= f.text_field :text %> <% end %> In controller I can get only category params in my params array. Maybe because I'm…
5
votes
1 answer

Rails 7 - ActiveRecord::Associations::Preloader.new.preload

consider this code: # in Rails 6.1 def preload(resource, relations) ActiveRecord::Associations::Preloader.new.preload(resource, relations) end So: I want to change that for compatibility with Rails 7 so I wrote this: def preload(resource,…
5
votes
4 answers

Rails Model no longer available in initializer after upgrade to Rails 7.0

I have a Rails initializer (features.rb) that must access a model (Report). Report.all.each do |report| default_to_enabled(report&.feature_name) end This all worked perfectly with Rails 6.1 using Zeitwerk and defaults set for…
iconoclast
  • 21,213
  • 15
  • 102
  • 138
5
votes
3 answers

Rails 6.1.4 - Ruby 3.0.1 - ActiveStorage and WebP image format

There is no good info about how to setup Rails for serving WebP images with ActiveStorage. Can someone explain how to do it? I try: application.rb config.active_storage.web_image_content_types = %w(image/jpeg image/png image/webp image/jpg) And in…
Wordica
  • 2,427
  • 3
  • 31
  • 51
5
votes
1 answer

What's the replacement for acts_as_commentable in Rails 6, Ruby 3.0.2?

I upgraded our app to Rails 6.1.4.4 and Ruby 3.0.2. I have this old gem gem 'acts_as_commentable' Locked at version 4.0.2. The gem does not appear to be supported anymore, which is a shame because when I start up my app or console, I now get this…
Dave
  • 15,639
  • 133
  • 442
  • 830
5
votes
2 answers

How do I test belongs_to associations with Rails 6 and RSpec 4.1?

I’m upgrading from Rails 4.2 to 6. I'm also using FactoryBot 6.2.0. I have this model class Book < ActiveRecord::Base belongs_to :author, inverse_of: :book … validates :model, presence: true, unless: -> { author.check_vwf? } I have an…
Dave
  • 15,639
  • 133
  • 442
  • 830
5
votes
0 answers

How do I do an `update ... from` in ActiveRecord?

I would like to do an update ... from, or an update using a CTE, but using ActiveRecord. Ideally so I can take advantage of in_batches. For example, Person has many Things and I'd like to cache their first Thing. I'd imagine it would work something…
Schwern
  • 153,029
  • 25
  • 195
  • 336
5
votes
1 answer

Integrate SAML in rails application

I am trying to add the ruby-saml in my project. But I am a bit confused about how to implement it in my scenario. I am on a website let's say abc.com and there is a button. When I click on the button, I need to redirect to the website xyz.com where…
Aniket Tiwari
  • 3,561
  • 4
  • 21
  • 61
5
votes
1 answer

How can I prefix cookies with __Host or __Secure?

I am trying to add prefix to session cookies in rails 6.0.3 app but couldn't find a way to get it done. I have tried adding key to options hash in session store but it didn't help and breaks my application. I am using auth-logic gem for…
Arsii Rasheed
  • 324
  • 1
  • 5
  • 18
5
votes
0 answers

Rails 6 are you trying to open an SSL connection to a non-SSL Puma?

I'm trying to set up Rails on AWS ECS with HTTPS access. When my ECS Service is deployed, these are the logs: => Rails 6.1.3.2 application starting in production => Booting Puma * Listening on http://0.0.0.0:3000 * PID: 1 * Environment: production *…
Sticky
  • 3,671
  • 5
  • 34
  • 58
5
votes
4 answers

How do I make Active Job retry all jobs forever?

I don't want active job to drop jobs when they fail. I want to have a chance to fix the failure and then let them re-run. I tried doing this: class ApplicationJob < ActiveJob::Base retry_on Exception, attempts: Float::INFINITY end but it didn't…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622