Questions tagged [ruby]

Ruby is a multi-platform open-source, dynamic object-oriented interpreted language. The [ruby] tag is for questions related to the Ruby language, including its syntax and its libraries. Ruby on Rails questions should be tagged with [ruby-on-rails].

ruby
Filter by
Sorted by
Tagged with
0 votes
0 answers
19 views

Rails_Admin issue on rails 7.1.3

I have updated a rails 5.0 to rails 7.1.3 apps. I have made the choice to use jsbundling insteead of importmap, as it seems easier to handle my existing javascript file. Now when I test the admin ...
Denis Morin's user avatar
0 votes
1 answer
18 views

Ruby on Rails bulk import

https://github.com/bodrovis-learning/RailsSeriesYT/blob/lesson_11/app/services/user_bulk_service.rb line 15 and 26 def call Zip::File.open(@archive) do |zip_file| zip_file.glob('*.xlsx').each do |...
Irina's user avatar
  • 1,069
0 votes
0 answers
51 views

Error: SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON checkout. Using stimulus on Ruby on Rails

basically I'm using stimulusjs in ruby ​​on rails to create an ecommerce, and I'm trying to assign the stripe to my application (remembering that the functionality is on the cart page), but basically ...
Felipe Almeida's user avatar
1 vote
0 answers
36 views

RVM Ruby 3.1.4 fails to install on macOS Sonoma due to perl5.18

I'm trying to install Ruby 3.1.4 version on Sonoma 14.4 with rvm and got this error: Error running '/Users/username/.rvm/src/ruby-3.1.4/autogen.sh', please read /Users/username/.rvm/log/...
Dolores's user avatar
  • 11
1 vote
1 answer
61 views

Ruby Case statements and pinning, does not work with attr_reader

This code works: class Hello def initialize @name = "Paul" end def say_name(maybe_name) name = self.name case maybe_name in ^name puts "Hello, Paul!" ...
Paul Byrne's user avatar
  • 1,585
0 votes
1 answer
32 views

Webpacker compile very slow with Docker

We have a rails 6 application that we just dockerized a few days ago (for development environment for now). We had some issues with the image we managed to fix and now the whole application runs ...
vr-prt's user avatar
  • 1
0 votes
1 answer
44 views

How can I warn about Ruby 3 deprecated code, while using Ruby 2.7 with Rubocop?

I'm working on a huge repo with many contributors, and many code changes happen daily. I'm tasked to update current Ruby 2.7.4 to Ruby 3+, and as a first step I have decided best to add some rules to ...
Guj Mil's user avatar
  • 335
0 votes
1 answer
32 views

Mongoid polymorphic associations with embeds

I'm confused on how to make polymorphism work with embeds and mongoid 8.x. class Entity include Mongoid::Document embeds_many :custom_fields, as: :item end class EmailField include Mongoid::...
ngw's user avatar
  • 1,262
0 votes
1 answer
35 views

Bootstrap Carousel (5.3) not working on Rails 7

I can't find the issue and I've tried a million times. Why isn't this code working? It's the same as in the Bootstrap website minimally modified. It just shows one picture, but the buttons are not ...
user23989224's user avatar
0 votes
1 answer
28 views

Integrating Opensearch with Ruby on Rails

Currently, my Rails application utilizes Elasticsearch with the elasticsearch-model and elasticsearch-rails gems for integration: require 'elasticsearch/model' class Article < ActiveRecord::Base ...
Khoa Nguyen's user avatar
-1 votes
0 answers
50 views

Performance-wise for large models, is it better to have many "to-many" associations, or to keep IDs in a string-column? [closed]

I am currently structuring an application where a model will have many large has_many associations. I can demonstrate it in an example below: class Car < ApplicationRecord belongs_to :...
user984621's user avatar
  • 47.3k
0 votes
1 answer
39 views

How to test a script that pushes gems?

I have this script: #!/usr/bin/env ruby # frozen_string_literal: true if ARGV.any? puts "USAGE: release" exit end def system!(command) puts command system(command, exception: true) ...
Dorian's user avatar
  • 8,643
0 votes
0 answers
17 views

Why Can't I update my contentful entry with ruby gem

I'm currently trying to update entries in contentful using ruby's gem (contentful-management). But it doesn't work. There are no errors and I can't pinpoint the cause. Below is the code and error. ...
minmin's user avatar
  • 53
0 votes
1 answer
52 views

Pagination on Home Page - Want http://website.com/submissions/?page=2, not http://website.com/?page=2

I'm using the Pagy Gem for pagination. What i'm trying to do is render the partial in my Home page with the pagination (this is working how I want currently), but I want the 2 in 1,2,3 Next > to go ...
Suedehead's user avatar
0 votes
1 answer
24 views

Bundle install unable to install gem from GitHub

I am trying to install gem from a forked aws-sdk-ruby repo where I have added some new commits. Below is the content I have added to my Gemfile: gem 'aws-sdk', :git => 'https://github.com/suvrat-...
sjgo's user avatar
  • 363
-1 votes
0 answers
26 views

config.ru path issue when upgrading from Ruby 2.7 to 3.2

I have an issue starting an old Rails app. When config.ru is called, the require_relative 'config/environment' statement is called in the context of 1 directory level up from my application directory,...
l33z3r's user avatar
  • 615
3 votes
1 answer
113 views

Why Ruby `num >> 1` is slower than `num/2`

i surprised that Ruby num >> 1 is slower than num/2 since i always thought that bit operators should faster than normal operators. # ruby 3.0.3 require "benchmark/ips" Benchmark.ips ...
Lam Phan's user avatar
  • 3,633
0 votes
1 answer
43 views

What extended do ruby

What extended does in this code? class << self def extended(klass) klass.class_exec do define_method :supported_attrs do that_klass = self.class that_klass....
Irina's user avatar
  • 1,069
0 votes
1 answer
37 views

GraphQL not working when deployed on Heroku but working correctly on local (Shopify ruby gem)

I use a ruby app with the shopify gem (version 9.0.2) Everything worked well, until recently, when suddenly it can't parse my GraphQL call on Heroku But when I am doing the same process locally, it ...
bseido's user avatar
  • 1
0 votes
2 answers
55 views

How to introduce a filename into shell script in Ruby script

Ruby script where I want to run a shell script and pass in a filename with spaces. I've tried a dozen ways of doing. Here's one: filename = "/Users/gscar/Pictures/_Photo Processing Folders/...
Greg's user avatar
  • 2,509
0 votes
1 answer
72 views

What each_with_object does in ruby

What each_with_object does? Where it get opts? https://github.com/bodrovis/lokalise_manager/blob/master/lib%2Flokalise_manager%2Ftask_definitions%2Fbase.rb#L23 primary_opts = global_config ...
Ирина Грачева's user avatar
-2 votes
0 answers
39 views

how to integrate cashfree payment gateway in ruby on rails project [closed]

i want to integrate cashfree payment gateway in ruby on rails, my project is built on ruby on rails at backend and React.js on froentend help me to integrate cashfree with checkout page of cashfree ...
Mohammad Humza's user avatar
0 votes
1 answer
27 views

RSpec Capybara throwing Selenium error when trying to click a button with browser confirm

I'm running into an error with an end-to-end Capybara spec in my Rails application. Here is the relevant part of my view: #show.html.erb ... <%= button_to 'Cancel', cancel_subscription_path, ...
Michael Evans's user avatar
0 votes
1 answer
58 views

Duplicate GET requests - Rails & Heroku

I'm trying a solution to resolve a duplication of requests happening in my Ruby on Rails 6 project deployed to Heroku. This seems to occur when those anchors with hyperlinks are used, so it loads 2x. ...
Caio Agiani's user avatar
0 votes
0 answers
31 views

convert csv file with json data inside to a column, rows table in 2nd csv file

Ruby newbtard here... I have an csv file (logevents.csv) that has a "message" column. The "message" column contains rows of json data. Using Ruby, I'd like to convert the json data'...
DLC's user avatar
  • 1
0 votes
1 answer
40 views

Installing dependencies from a gemspec file

I wish to work on an existing gem, which I've checked out from a git repository. I'm using a clean Ruby installation. To start, I would like to install the dependencies specified in the gemspec file ...
Chris Reuter's user avatar
  • 1,548
0 votes
0 answers
29 views

Verifying Google Identity OAuth2 token with Ruby

I have a Rails API with a variety of frontend clients. I’m setting up Google Sign-in/up with OAuth2 (via Google Identity), and am having issues verifying the token that comes from Google - it seems ...
michaelsking1993's user avatar
-1 votes
0 answers
41 views

Java code of AES/GCM/NoPadding encryption algorithm with authentication tag

I am trying a ruby code convert in java but java code always gives javax.crypto.AEADBadTagException: mac check in GCM failed. I have tried different java implementation from online but all of the ...
Forhad Naim's user avatar
0 votes
0 answers
36 views

How to fix error in model with gem lockbox

I am using ruby '2.5.9' and rails '4.2.11.3'. I configured all needed things for this gem. I have db with column "password_ciphertext", In model: "has_encrypted :password". When I ...
Rom4ik617's user avatar
0 votes
0 answers
33 views

Cannot install Ruby Gem on Window

I installed the latest Ruby with DevKit (version 3.2.3) on a Windows 11 machine (always up to date). However, I failed to install Rails with the following message (at the bottom). It seems the core ...
Thai Anh Duc's user avatar
-1 votes
0 answers
52 views

use logstash filter ,aes gcm encrypted in ruby,but cannot decrypted in java

ruby class LogStash::Filters::Cipher < LogStash::Filters::Base begin data = event.get(@source) if @mode == "encrypt" @random_iv = OpenSSL::Random.random_bytes(@iv_random_length) end @...
longenflew's user avatar
0 votes
0 answers
31 views

In Rails 7, what is the right ActiveRecord callback to use if I need to prevent (or rollback) persistance on error?

I'm moving from Rails 6.1 to Rails 7.0, and one of my tests is failing due to a record being persisted into the DB even after an error is raised in the transaction where the saving occurs. Something ...
Mauricio Chavarriaga's user avatar
-1 votes
0 answers
53 views

How can I go through an array and still remove elements from it [closed]

How to iterate through an array starting from the last element? (Ruby) Looks similar but removing elements seems to causing lots of problems such it has no effect. It is RGSS so use really simple code....
user2617804's user avatar
-2 votes
0 answers
46 views

Nokogiri only returning 5 results [closed]

I want Nokogiri to return all the divs with the following class: styled__PostItemWrapper-sc-e4ns84-7 however on my webpage, I can see so many divs with this class, here is a sample: yet when I do ...
Adam Afzal's user avatar
0 votes
1 answer
57 views

How do I get the fullscreen mode in firefox?

I've successfully achieved fullscreen mode in Chrome using the following WATIR code: require 'watir' chrome_options = { args: ["--start-fullscreen"] } b = Watir::Browser.new :chrome, options:...
Rajagopalan's user avatar
  • 5,879
-1 votes
0 answers
29 views

undefined group option when using branch reset group regex in Ruby [duplicate]

I'm working with Ruby and I have a regex to match a pattern: REGEX = /(?|"([^"]*)"|'([^']*)'|(.*))/ (https://regex101.com/r/t2jXuu/1) It works very well as I can test with regex101, ...
iAmoric's user avatar
  • 1,907
2 votes
3 answers
83 views

Regex: match string with or without quote

I'm trying to extract a value using regex. This value can be quoted or not: For example: foo: "bar" or foo: 'bar' or foo: bar How can I extract only bar value? Here is the regex I use: ^(...
iAmoric's user avatar
  • 1,907
0 votes
0 answers
31 views

How to compile & run Ruby c (/c++) extension with OpenMP (undefined symbol error)

I'm trying to do a simple parfor loop in a Ruby c/c++ extension using openmp #pragma omp parallel for for (int j = 0; j < 100; j++) { } extconf.rb: require 'mkmf' extension_name = 'stridx' $CFLAGS ...
Sami Sieranoja's user avatar
1 vote
1 answer
38 views

Ruby Threads Concurrency Issue using Mutex

require 'thread' mutex = Mutex.new shared_resource = 0 for i in 0..10000 Thread.new do mutex.synchronize { shared_resource += 1 } end Thread.new do mutex.synchronize { ...
Santosh Mohanty's user avatar
0 votes
1 answer
67 views

Correct Alphabetical Order - platform-wide solution

Currently in our app we do not override the system’s default method for alphabetizing data, it will sort capital letters over lowercase letters. How to enable case-insensitive across the application ...
VDN's user avatar
  • 508
1 vote
1 answer
51 views

Errors are being swallowed inside ViewComponent, Ruby on Rails

Hoping you're having a good day. So, i have this weird bug that's been kicking my ass and i'm not sure where it is located for the love of God. I have a ViewComponent that is rendered normally inside ...
Ahmed Khattab's user avatar
1 vote
0 answers
49 views

NameError: uninitialized constant SvgGenerator (NameError)

was updating a rails app to 7.1.3 and when I run 'rails zeitwerk:check' I got this error message. NameError: uninitialized constant SvgGenerator (NameError) parent.const_get(cname, false) ^^^^^...
Denis Morin's user avatar
0 votes
1 answer
26 views

I want to install Cocoapods for flutter but it gives me such ERROR:

Error installing cocoapods: The last version of drb (>= 0) to support your Ruby & RubyGems was 2.0.6. Try installing it with gem install drb -v 2.0.6 and then running the current command again ...
Safiya Dodojonova's user avatar
0 votes
1 answer
33 views

Is there a way to create a has_many association that just filters items from another has_many association?

Basically I have a has_many association. I want to create another association that just filters items from the original association. class Track belongs_to :playlist end class Playlist has_many :...
acanthite's user avatar
  • 113
0 votes
0 answers
30 views

Relation RubyGems, Ruby Version, Bundler Version, RVM and Capistrano Conflict

I have an ancient Ruby on Rails project that uses a Capistrano installation process. It currently runs Ruby 2.5.1 and Rails 5.2. I have been working on an updated version and while doing so probably ...
MDickten's user avatar
  • 117
0 votes
0 answers
38 views

Is there a simple way to set AWS tags when uploading to S3 with ActiveStorage?

I want to set AWS tags when uploading to S3 with ActiveStorage. However, S3Service does not support that, even though the underlying aws-sdk-s3 library does. I've actually managed to implement this, ...
Eugen Dück's user avatar
0 votes
0 answers
25 views

How to solve the undefine method and expand path error in Bundler [duplicate]

I ran the command line: $ bundle exec rackup --host 0.0.0.0 --port 3000 But got this error: D:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/bundler-1.17.3/lib/bundler/shared_helpers.rb:272:in `search_up': ...
Yu Fu's user avatar
  • 1
0 votes
0 answers
45 views

Error running a rails project after updating versions

I'm updating Ruby and Rails versions of a project and i'm having this issue trying to run the server. Searching i found that it could be due to incompatible versions, but i found many articles saying ...
Lucca Oliveira's user avatar
0 votes
1 answer
39 views

How can I properly delete a cache key on a Ruby on Rails project using memcached on multiple nodes?

My ROR project is currently utilizing memcached (3 nodes) on AWS elasticached to circumvent reading from the database. When trying to delete the key, it seems like Rails or Memcached is often only ...
nullnullnulls's user avatar
1 vote
2 answers
64 views

How to generate a 16-digit robust not guessable coupon code?

I am looking for a robust ruby code to create 16 digit not guessable coupon codes. I.e. AH9A-TE9A-443G-TGRW There is a promising pseudocode at this answer written by Neil Slater # Random, unguessable ...
wuarmin's user avatar
  • 3,679

1
2 3 4 5
4581