229,271 questions
0
votes
0
answers
62
views
How to implement a callback using PyCall?
I would like to access a Python package in Ruby using PyCall.
The non-blocking function in the Python code below activates a callback.
Could you help me implement the callback?
#!/usr/bin/env python
# ...
1
vote
2
answers
81
views
Replace a long case statement involving regex with a hash
I'm parsing a number of text files of different formats. Some are csv, some are xml and some even txt. I have a case statement that checks if a certain string is contained in the first 100 bytes of a ...
0
votes
0
answers
49
views
CocoaPods install error: “version of CocoaPods used to generate the lockfile (1.16.2) is higher than the current executable (1.15.2)” in react native
I'm working on a React Native iOS project using React Native 0.81.4, and I'm getting a CocoaPods–related error when running:
Installing Ruby Gems
Installing CocoaPods dependencies with New ...
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': ...
2
votes
2
answers
337
views
Ruby SSL_connect certificate verify failed: unable to get certificate CRL on macOS
m getting an SSL error when making an HTTPS request in a Rails controller (Ruby 3.1.6):
OpenSSL::SSL::SSLError in PurchaseAttemptsController#create
SSL_connect returned=1 errno=0 peeraddr=3.175.45.47:...
-2
votes
2
answers
68
views
Deploy zip to AWS application
I have been asked to look at an old Ruby application that is currently deployed to AWS via CodeShip on successful build.
CodeShip is obviously gong out of service end of Jan 26 and I need to deploy ...
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....
-1
votes
0
answers
45
views
binding.pry debugger not working on Windows 11
I'm running into issues with binding.pry on Windows 11. When I insert it into my Ruby script, the program reaches that line but either skips over it or pauses without accepting any input.
🧪 Problem:
...
0
votes
1
answer
44
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....
5
votes
1
answer
117
views
Symbol#to_s, Array#last, Time.now undefined or no-ops when evaluated using Ruby 3.x C API
For several years I've been using the Ruby C API to add the ability to use Ruby code in my C text editor (a variant of MicroEMACS). This has been working well in Linux Mint 21 (essentially the same ...
Advice
1
vote
1
replies
122
views
Is it possible to embed a Ruby interpreter in a Flutter app?
I see that it is supposed to be possible to embed a Python interpreter in a Flutter app, so can I assume it should therefore also be possible to do this with a Ruby interpreter? (I would be happy ...
1
vote
2
answers
99
views
Why does adding an subsequent if-else block cause another previous if-else block to return nil?
I am a beginner in Ruby and I am having trouble with if else statement. As you know, Ruby will return the last calculated code if the return keyword is not specified.
Here is the issue.
def aMethod(*...
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 ...
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, ...
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 ...
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 ...
1
vote
1
answer
170
views
Why does IRB display arrays differently depending on their length?
I am currently experimenting with arrays in irb.
If my array has 22 elements, it will display properly as shown below: (Screenshot)
#Ruby Version 3.4.7
x = 1..22
#=> 1..22
x.to_a
#=> [1, 2, 3, ...
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
0
answers
45
views
rbenv: issues with ruby-build plugin
I am trying to set up a virtual ruby environment on linux. The systems are managed by puppet. I have installed rbenv and ruby-build vis puppet and I can use rbenv install ... from the command line ...
0
votes
1
answer
56
views
Anyway_config RSpec tests fail with undefined method 'with_config'
I am trying to use anyway_config for the first time in a plain Ruby program with RSpec tests. The docs do not give as much guidance as I would like. The end of this posting shows the pressing issue ...
0
votes
1
answer
81
views
Finding the class name of an ancestor in the call stack in Ruby
I am trying write a method that interrogates the call stack to determine if it was called by a specific class. The caller in question would be dynamically generated (by ActiveRecord, as it happens), ...
4
votes
1
answer
203
views
Render a partial view outside controller
Context
I've written an internal standalone gem that generates PDF with Gotenberg rendering an ERB HTML template dynamically. This permits to actually generate a PDF outside a controller context for ...
0
votes
1
answer
85
views
http 404 when switching to a different proxy
Context: I have a Cloudfoundry app running on Ruby 3.0. I'm using a forward proxy to access an external API and that proxy is going away soon so I have to switch to a new service.
Problem: When I ...
0
votes
0
answers
84
views
Tailwind CSS still loads and applies utility classes after removing stylesheet_link_tag in Rails 8 app
I’m working on a Rails 8 app using the tailwindcss-rails gem.
In my layout (application.html.erb), I commented out the line:
<%#= stylesheet_link_tag "tailwind", "data-turbo-track&...
0
votes
0
answers
39
views
AngularJS + Compass project fails to run locally on Windows (grunt dev / SCSS )
I’m trying to run an old AngularJS project locally on Windows 11. The project uses:
SCSS with Compass
Pug templates
Grunt tasks (grunt dev / grunt build)
Node.js + Bower
According to the README, I ...
0
votes
0
answers
84
views
Rails API: Devise/Warden intercepts API requests causing "No Failure App provided" error
I’m working on a Rails 8 API application where I have separated API routes from my admin panel:
namespace :api do
get 'test', to: 'clerk_test#index'
end
devise_for :admin_users, ActiveAdmin::Devise....
-1
votes
0
answers
111
views
Test for text content of generated PDF in new tab with cucumber feature
I have a web application in Ruby on Rails which uses the wicked_pdf gem to render a PDF. A week ago the PDF rendering failed and my test suite running didn't show because a test was missing. The ...
2
votes
0
answers
71
views
Need to do CPU profiling of Jruby application
Need to do CPU profiling for Jruby application (jruby version : 1.7.20.1-8) which uses ruby version (1.9.3).
I tried using default profiler but getting below error due to version compatibility issue ...
1
vote
1
answer
99
views
Ruby 3.2.4, GRPC 1.74.0 Segmentation fault
Just leaving it here cause I couldn't find a solution on web by myself and had to experiment for a long time to make it work.
What I have:
Ruby 3.2.4, Rails 7 and the GRPC gem of version 1.74.0
...
2
votes
1
answer
69
views
Stub a method on a Thor CLI
I have a Thor class that has a getter method defined like this:
# Playgrounds CLI skeleton class.
# Commands are added from commands folder
class CLI < Thor
def self.exit_on_failure?
true
...
0
votes
2
answers
58
views
Directory file task with rake
I have a rake task that require_relatives a ruby file and then calls a method defined in that file. That method fills a directory with new files, creating the directory if necessary.
If I make my rake ...
0
votes
0
answers
71
views
Bundler option to use older Ruby headers?
I am running some old ruby code and it misbehaves with the latest versions of some dependencies. I can change the dependency version in the Gemfile and then ask bundle to install the dependencies.
The ...
0
votes
0
answers
46
views
ruby documentation that reports missing doc for parameters to methods
I use doxygen in most projects (C/C++, python), but doxygen does not support ruby (even though Gemini AI says it does).
I tried rdoc. There were issues with it, so I looked for another tool. I'm now ...
0
votes
1
answer
55
views
ruby warning: Ignoring llhttp-ffi-0.5.1 because its extensions are not built
On one of my linux machines (Ubuntu 24.04) I get warning whenever I run a ruby program. The suggested solution gem pristine makes no difference. The machine has build tools installed.
rful011@...
-1
votes
1
answer
103
views
OpenSSL::Cipher::CipherError Rails 7 does not decrypt manually
I'm having some trouble to decrypt ciphertext that was added to my logs using Rails 7.1.5.1
I recently added the Rails Encryption and made the upgrade to Rails 7 and now I need to decrypt logs that I ...
2
votes
1
answer
121
views
Ruby's class Data vs traditional class (without setters)
I'm currently reading about Ruby's Data class: Ruby docs - Data class
I understand how it has to be used and that it is intended for storing immutable data. But I'm not clear about the motivation ...
0
votes
1
answer
61
views
How to specify apache login credentials in ruby HTTP:post_response call
I have a redmine (5.1.9) server running on apache (2.4). When processing email replies, it fails trying to post an HTTP request to itself. I believe this happens because the apache server itself ...
0
votes
1
answer
60
views
Finer caller_locations with line/column ranges
Is it possible to retrieve more than the file and the start line of the call stack in Ruby? Consider the following model file:
# sample.rb
def sample(a = nil, b = nil, c = nil, &block)
yield if ...
2
votes
2
answers
154
views
Accessing a module's variables from within methods of a class within the module
I have inherited a Ruby codebase which tries to implement a singleton pattern by nesting a class within a module like so:
module ModuleA
class ClassA
def methodA
...
end
end
def ...
1
vote
1
answer
112
views
What's the difference between "binding.break" and "debugger"?
What's the difference between ...
binding.break
@vendors = Vendor.all
... and ...
debugger
@vendors = Vendor.all
?
I can't notice any difference. They both seem to do the same.
Is there any ...
0
votes
0
answers
59
views
Where becomes RAILS_ENV its value? [duplicate]
When I read the RAILS_ENV environment variable, it returns "development".
irb(#VendorsController:0x0000000...):001 ENV["RAILS_ENV"]
=> "development"
All good and well.
...
21
votes
2
answers
2k
views
Why does the result of applying the minus operator depend on newline characters surrounding it?
If I run this very simple program:
x = 1
y = 2
puts ( x -
y )
puts ( x
- y )
puts ( x - y )
I get this output (!):
-1
-2
-1
However, I would expect this to print:
-1
-1
-1
I.e., -1 ...
1
vote
1
answer
130
views
How to exit around_save callback before executing yield block
Currently upgrading an app from Rails 4 to Rails 5.2.
I'm trying to determine how you handle the around_save callback, where you want to exit based on logic, before you execute the block.
When using a ...
1
vote
2
answers
149
views
What is the right column type to use for storing currency amounts?
I have this fintech application (written in Ruby with some JS micro-services) which stores transactions in a database table, amounts are stored as integers in cents, eg $123.45 is stored as 12345, -...
1
vote
1
answer
148
views
Handle an array as a Ruby method would
I'm well aware of Ruby's splats and double-splats in methods
def method(*arg, **kwarg)
:
end
method('foo', bar: 'baz') # arg = ['foo'], kwarg = { bar: 'baz' }
but how would one do that processing ...
1
vote
1
answer
172
views
Bootstrap components stop working in Rails app when any links clicked
In my rails 8 app I followed the Bootstrap Getting Started instructions to pull in bootstrap version 5.3.7 via the link tag:
I put the following in the head tag of application.html.erb:
<link href=...
0
votes
0
answers
60
views
How to force rbenv to use local version instead of system binary
I have set-up rbenv which sets my local version properly.
However when I use executables like ruby or gem, it still uses (macos) system defaults
My rbenv local setup shows correctly
[(adikshit@...
1
vote
1
answer
156
views
Why does saving fail with a mutual belongs_to association in ActiveRecord?
This code may be difficult to understand at first glance, but it was created solely to reproduce an unusual behavior and does not represent actual application code.
Therefore, comments such as “the ...
0
votes
1
answer
188
views
Shorthand for converting ruby procs to duck type / functional interface [closed]
I am given a "duck type" of a single method (a "functional interface") and I have a whole flock of adapters as methods and blocks.
For example, the protocol defined by the library ...