338,179 questions
0
votes
0
answers
66
views
rails 8 error: Uncaught SyntaxError: import declarations may only appear at top level of a module
I have a new Rails 8 application built with Bootstrap, Ruby 3.4.7, MySQL, and Haml, running in Firefox 145.
It all looks good, except for the uncaught exception:
Uncaught SyntaxError: import ...
0
votes
0
answers
48
views
Rails App, Auto loading files during initiliase phase
I have a Rails 8 app that is pretty bare boned.
I'm just setting up my dependency injection container, which registers relevant services here at:
config/initializer/command_bus.rb
The issue is that I'...
-3
votes
0
answers
90
views
Error in PostgreSQL when running Rails and PostgreSQL using Docker Compose
When I run the command on docker container backend:
psql -h localhost -p 5432 -U postgres
I receive the following error:
psql: error: connection to server at "localhost" (::1), port 5432 ...
0
votes
0
answers
45
views
MiniMagick/ImageMagick produces Grayscale PDFs(contains colourful images) inside Docker, but Color PDFs Locally (Rails 8)
The Problem Statement
My Rails 8 application uses MiniMagick to composite multiple color JPEG/PNG images onto a single blank page, draw bounding boxes, and output the result as a PDF.
When running the ...
0
votes
1
answer
47
views
Assertions for travel_to with attribute-based timezone
At 10 a.m. an object becomes active and visible to the user.
seconds_since_midnight.to_i at 10:00 is 36000, but that is not timezone aware.
application_controller sets a tenant and its timezone, based ...
0
votes
0
answers
53
views
Getting Rails 6 error after upgrading from 5.2 to 6.0.6
Here is the error:
bundle exec rails app:update:bin
/home/ubuntu/.rvm/gems/ruby-3.1.2/gems/activesupport-6.0.6.1/lib/active_support/logger_thread_safe_level.rb:16:in `module:LoggerThreadSafeLevel': ...
0
votes
2
answers
58
views
Can't connect to MongoDB Atlas (free tier)
I'm struggling to connect from my Rails deployment to an Atlas Cluster.
This is my MONGODB_URI:
mongodb+srv://JohnDoe:****@cluster0.*****.mongodb.net/XYZ_prod?retryWrites=true&w=majority
The ...
0
votes
0
answers
54
views
Properly submitting array of data for a minitest
The following params are submitted in different actions the following manner
?acc_ids%5B%5D=246&acc_ids%5B%5D=247&acc_ids%5B%5D=248 with Parameters: {"acc_ids"=>["246", &...
0
votes
0
answers
52
views
How to add [page] , [topage] in the body of PDF [closed]
I am confused about generating the PDF. I have a case
Table of content
A-1 .......................................................................... 2
B-2 ..............................................
0
votes
2
answers
80
views
error installing rails - alternate installation path possible
I want to install Rails on Windows using the procedure described in the official Ruby guide.
When I enter
gem install rails
I get the error message:
Permission denied @ rb_sysopen - /var/lib/gems/3....
0
votes
1
answer
62
views
Problem with migrated rails 8 sprockets/importmap sprockets errors on app/javascript files
I upgraded an app from rails 5.2 to 8.0.4, still using sprockets to load all assets, but everything was working properly. I then added importmaps and migrated all my javascript files to importmap. I ...
0
votes
1
answer
100
views
Turbo Rails (8x) with `link_to` raises "Can't verify CSRF token authenticity"
I have a button_to tag, with data: {turbo_method: :post}
This works.
When I change it to link_to it breaks with Can't verify CSRF token authenticity.
Is this a bug? It seems that it should work ...
0
votes
1
answer
51
views
ActiveAdmin complaining about ransackable_atttributes
I'm currently trying to migrate to activeadmin 3.0.0, which requires ransackable 4.3.0. This breaking change require to add ransackable_attributes and ransackable_associations as class methods in my ...
0
votes
1
answer
73
views
Rails 8 importmap and chart.js
Installing chart.js to Rails 8 with importmap
Install package
bin/importmap pin chart.js
Pinning "chart.js" to vendor/javascript/chart.js.js via download from https://ga....
Best practices
0
votes
3
replies
52
views
How should I structure NestJS services when one endpoint needs to update multiple entities (e.g., InvestorProfile and TaxProfile)?
I’m working on a NestJS + TypeORM backend and ran into an architectural question as my codebase evolved.
Initially, I had a simple setup:
InvestorProfileController handles PATCH /investor-profile
...
0
votes
1
answer
43
views
Rails logs show `DEBUGGER: Debugger can attach via UNIX domain socket` but VS Code rdbg says "Can not find attachable Ruby process."
I have two Rails apps that I want to debug with the VS Code rdbg Ruby Debugger extension.
For each of them, I have a launch.json that looks like this (abbreviated):
{
"version": "0.2....
Tooling
0
votes
0
replies
54
views
Rails form components with Phlex
How are people building form components with Phlex? Using the gem Superform, calling Rails form_with helper in the Form component, or something else?
My current form field helpers are pretty ...
Best practices
2
votes
2
replies
112
views
copying and deleting a collection of records from one postgresql table to a second table
Two tables with identical attributes exist: itemised_origin_rows and the target second table itemised_rows .
They exist because archival requirements are different: based on certain transactions they ...
0
votes
1
answer
92
views
Can't get rails to match a nested controller to its layout
I have this rails controller:
module Admin
module Settings
class PrintersController < ApplicationController # BaseController
end
end
end
I believe I should be able to match a layout ...
0
votes
0
answers
65
views
Rails 8 migration: remove sprockets dependencies
I migrated my application to Rails 8 some time ago, and at the time noticed that it wasn't using propshaft, it was still running sprockets even though the Gemfile might suggest otherwise. I wasn't too ...
3
votes
1
answer
109
views
Rails8/Devise custom action found in routes, but 404 when called
I'm extending the Devise invitations controller to lookup the email of the invitee to pre-populate the registration form. I'm getting an error:
#<AbstractController::ActionNotFound: "Could not ...
1
vote
0
answers
81
views
bundler error when running tests, but not in development
A minitest is launched and ends up running, but in the meantime is now generating a series of warnings. Mise was very recently installed to replace rbenv. The warnings are:
.local/share/mise/...
0
votes
1
answer
45
views
Rails 7 / GraphQL-Ruby: ActionCable subscription always 403 Forbidden when connecting with JWT
Problem Description
I'm trying to set up GraphQL subscriptions in a Rails 7 backend using ActionCable. The subscription works from the Rails console — I can broadcast events and they are received. ...
0
votes
1
answer
76
views
How can I use Rails internal error reporting to swallow the error in production but not in test or development
If I use:
Rails.error.handle do
my_possible_error_code
end
The possible error is swallowed and never raised.
If I use:
Rails.error.record do
my_possible_error_code
end
The possible error is ...
1
vote
1
answer
73
views
Unable to set up Ahoy with JS in Rails app
I set up Ahoy to work with my Rails app and ahoy.track each time a user loads a page. It's working neatly but I'd also like to track some more client-side actions such as a button clicks, moving ...
0
votes
0
answers
103
views
Spotify oAuth from mobile web to the spotify mobile app
I have a rails app I am trying to reduce signup drop off on by implementing a 'sign up with spotify' flow for mobile users which does not redirect users to the spotify web page, but instead ...
0
votes
0
answers
49
views
`rdbg --open -c -- rails g` waits for debugger before running `rails` itself but detaches before actual generator code invoked
I'd like to attach a debugger (in my case, VS Code) to code used in a Rails generator.
I expected this command to work:
rdbg --open -c -- rails g my:generator
As described at https://github.com/ruby/...
0
votes
0
answers
45
views
Setup Google Tag Gateway with AmazonLoadBalancer
I have been tasked with setting up Google Tag Gateway for the website at work, and am struggling to understand how to get this done. We use rails backend and ALB and Route53 to route requests to our ...
1
vote
1
answer
111
views
undefined method 'arity' for an instance of Hash when upgrading rails 8.0.3 => 8.1.0
After upgrading from Rails 8.0.3 to Rails 8.1.0, my application crashes with an undefined method 'arity' for an instance of Hash error.
The issue appears to be related to the acts-as-taggable-on gem, ...
0
votes
1
answer
86
views
Rails 8: I am permitting a parameter but still can't access it
I can't get access to a param that i'm permitting. My log is showing this for the params
Started POST "/user/update_preferences.json" for 127.0.0.1 at 2025-10-25 16:46:46 +0100
Processing ...
-1
votes
1
answer
160
views
Replicating Rails development environment functionality
Background: I'm using Rails 8 out of the box and this is my first time working with Propshaft.
Goal: Create a custom environment that behaves identically to Rails' default "development" ...
0
votes
0
answers
103
views
Why is Rails generating separate cookies for subdomains?
I have a Rails 6.1 application that previously used to serve assets from /assets (asset_host was unset)
Recently I've changed the asset_host to use //assets<X>.example.com/ where X would be a ...
-1
votes
1
answer
90
views
How to make jsbundling-rails and yarn work together?
Issue:
jsbundling-rails can not use yarn build on production server.
Cause:
Inability of to access nvm packages through ssh.
After login on server: which yarn > /home/[user]/.nvm/versions/node/v25....
0
votes
1
answer
100
views
Script to start the Rails server does not work when I use crontab
My script to start the Rails server does not work when I use crontab. I have a script to monitor whether Puma is running or not, and subsequently start the Rails server in production. When I execute ...
-1
votes
1
answer
59
views
How to break out of a turbo frame for redirect on a form submit
I am trying to dynamically render form errors using a turbo-frame. This works great when there is an error and correctly to populates the form with the submitted params, but when the form submit is ...
1
vote
1
answer
93
views
How to use automatically generated service worker example in Rails 8? [closed]
I realised that Rails 8 generated automatically a service worker file for a new app.
It seems to be useful for web push notifications, and I would like to use push notifications but I do not know how ...
0
votes
0
answers
57
views
setting up an ActionCable connection using Devise
It is somewhat unclear to me given the rails guide instructions how to define the verified_user. The documentation suggests:
if verified_user = User.find_by(id: cookies.encrypted[:user_id])
if ...
2
votes
3
answers
223
views
Rails App crashes when https request is made after upgrading to macos Tahoe 2025
I recently upgraded to macos tahoe now my rails app crashes with a segmentation error bug whenever i make an HTTPS request. It should be noted that i do not experience any issue when i make http ...
0
votes
2
answers
71
views
How to create a Capistrano hook but only within the context of another task?
In Capistrano 2 the deploy:cold task looks like this:
namespace :deploy do
task :cold do
update
migrate
start
end
task :migrate do
...
end
end
I would like to create a ...
0
votes
0
answers
62
views
Spinner for rails turbo-frame while lengthy action completes
a view block within a turbo frame tag has:
an IDed div
<turbo-frame id='loader'>
<div class="loader">
<div class="inner one"></div>
<div ...
0
votes
1
answer
61
views
Active Storage creating variants at root of S3 bucket
All is working fine with Active Storage to add an image to one of my records.
However, when I create a variant, it appears at the root of my S3 bucket, along with the file blob - e.g. ...
0
votes
2
answers
65
views
Turbo not working when form is hidden then dispayed toggling display attribute
In a rails 8 application I have two models: Recipe and Ingredient
In the "show" action for recipe I display all the child ingredients, one per row.
Each ingredient has edit and delete links, ...
0
votes
1
answer
73
views
Sidekiq cron job runs multiple times only on the 15th of each month (same schedule works fine on the 1st)
Sidekiq cron job runs multiple times only on the 15th of each month (same schedule works fine on the 1st)
My config/sidekiq.yml, I am using the built-in Sidekiq scheduler.
:concurrency: 5
:queues:
- ...
1
vote
2
answers
574
views
How to handle Seahorse::Client::NetworkingError with certificate verify failed error
I'm running a Rails 8 app with a Option model that configures active storage like so:
has_one_attached :picture do |attachable|
attachable.variant :small, resize_to_limit: [75, 75]
end
config/...
0
votes
1
answer
115
views
Validate attribute uniqueness on association
In a Rails app, I have the following three models.
class Task < ApplicationRecord
has_many :project_items
has_many :projects, through: :project_items
end
class Project < ApplicationRecord
...
0
votes
1
answer
131
views
Adding a simple ERB template to the existing Rails scaffold process?
I can't seem to find a straight answer on this and AI is even leading me a stray. This is the closest post on this:
Overriding Scaffold Controller in Rails 7.1
In my app I have the standard *.erb.tt ...
0
votes
0
answers
43
views
Ransack filtering with EAV structure: how to AND multiple conditions on different associated rows?
I am using the Ransack gem.
I am using an Entity Attribute Value design in my database, specifically:
I have a model called Subreport, which has_many Myvalues, with a column called myvalue.
I have ...
0
votes
1
answer
45
views
Is it possible to abort outdated requests in StimulusReflex?
I have a Rails app with a search form where search queries are submitted via Stimulus Reflex as the user types.
I'm using a Page Morph and the results are populated into a div with data-reflex-root='#...
1
vote
1
answer
73
views
How to directly test ActionController::RoutingError for an invalid path in Ruby-on-Rails-7.1?
In Rails Controller tests of an invalid route, this used to work before Rails-7.1 (in Minitest):
assert_raises(ActionController::RoutingError){ get "/non_existent" }
In Rails-7.1 (or later),...
1
vote
1
answer
79
views
Inconsistent behavior of route helpers with friendly_id [closed]
I have added friendly_id to a rails project and despite everything working as expected, one test is broken and I cannot figure out why:
The model in question is called species, so with slugs generated ...