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].
227,654
questions
0
votes
0
answers
26
views
Rails server running but it won't load app
I am running a rails server on port 3001 but the page seems to get stuck on waiting for localhost. The url is localhost:3001 and the app just won't load up. I don't know how this happened all of a ...
1
vote
1
answer
29
views
Downloading files using wildcards with scp in Ruby
I am successfully downloading the log files in "log_list" from the server to destination using the code below.
I am using net/ssh / net/scp : (https://github.com/net-ssh/net-scp)
log_list = [...
0
votes
1
answer
23
views
What's the use of having a loop block inside Thread.new in ruby?
I am a beginner when it comes to multi-threading. I am trying to understand how Thread in ruby works, and saw this example from this website (Thread-safe Data Structures)
require 'thread'
queue = ...
0
votes
1
answer
20
views
Psych errors after Rails version update
We recently updated a client's application from Rails 4 to rails 5.
However, after running the test suite the following issue appeared whilst trying to create an object:
Failure/Error:
...
1
vote
1
answer
11
views
Grape API malformed parameters
I'm trying to make a post endpoint, with multiple nested parameters but the params are not as expected
I have the following parameters definitions for the endpoint:
params do
optional :profiles, ...
0
votes
0
answers
5
views
ruby-odbc and asynchrone execustion
I am trying to use ruby-odbc and I cannot find a way to run query asynchronously.
I tired to adapt this c code.
The first difficulty is that SQL_ATTR_ASYNC_ENABLE is not define in ruby-odbc binding. ...
0
votes
1
answer
25
views
Rspec fails after Rails version update
I got into a new project that hasn't been touched for a couple of years prior, the clients want me and my team to update Ruby/Rails from Rails 4 to the newest possible version without breaking the way ...
0
votes
0
answers
13
views
Extracting data from pdf in specific format
I want to extract the data in form of a hash. The text is like this. Sometimes there is a single Arrest type and multiple charge and charge description and sometimes one Arrest type and one charge and ...
-1
votes
0
answers
14
views
How to integrate Rubycritic with CircleCI in rails to see a result at a PR on GitHub?
is there some guide how to integrate RubyCritic gem with CircleCI? I just want to see some report (score/percentage) from RubyCritic on GitHub. I already use CircleCI jobs for GitHub, but I can't set ...
0
votes
0
answers
10
views
Multiple dock in one project with rswag rails
I try to create 2 docs for my api. I have 2 namespaces in routes and I need to create 2 docs for my first namespace and second namespace. In request test they are divided on 2 folders. How can I ...
0
votes
1
answer
12
views
Ruby: Monkey patch selenium driver
What I want ?
I want to extract all the capabilities from driver instance, as soon as it is created.
Setup
I am creating a fresh driver instance.
def create_my_selenium_driver
@driver = Selenium::...
0
votes
0
answers
22
views
loop through array of array using each function
I have to iterate through check_programs which contains program_enrollments to see if they include "btest"
.Both of them are arrays.
How do i write it using each do??
if check_programs[1]....
0
votes
0
answers
11
views
Setting up repo
While running "bin/setup" command on setting up the arcadia power repo. I am facing this issue
Your bundle is locked to envied (0.11.2) from rubygems repository https://gem.fury.io/...
0
votes
1
answer
38
views
Just started learning Ruby; Why does my code work properly in the Codeacademy environment but not in the Mac Terminal?
Completed a mini project on Hashes & Symbols, and wanted to see how it ran in the terminal.
It executes perfectly in Codeacademy, but in the terminal it's printing out the wrong responses, ...
0
votes
0
answers
26
views
Google drive API - ClientError - insufficientFilePermissions
I want to have access to a user's google drive, create a folder and save files in the user's drive. I have a client request where I get a token and save it on my db, then use it to create a Google ...
0
votes
0
answers
47
views
Ruby on Rails call to method appears to never happen
I have a student_admissions controller with a show and foo methods. My intention is to have a button to send an email when a student passed an admissions threshold so I do not have a view named foo as ...
0
votes
0
answers
15
views
How are equal hashes from multiple gitlab.rb files merged?
In a GitLab configuration file (gitlab.rc) an additional config file can be referenced:
from_file "/home/admin/external_gitlab.rb"
The documentation states the following:
Any configuration ...
1
vote
1
answer
22
views
How to create a status check on Github for lines not covered by test?
is there any way how to create a status check that will fail when some test is missing for added line? I am getting this warning by Codecov now, but I want to block merge every time when test is ...
-1
votes
0
answers
24
views
How can we share modals between two ruby on rails applications? [closed]
Possible ways/methods to share code between two ruby on rails applications.
I have tried the git submodules but failed.
1
vote
1
answer
41
views
What is the Ruby ActiveRecord equivalent for this SQL?
What would be an optimized (fast) ActiveRecord equivalent in Ruby:
SELECT DISTINCT customers.city
FROM customers
INNER JOIN (
SELECT c_id
FROM carts
WHERE shop_id = #{`shop_id`}
ORDER BY ...
-1
votes
2
answers
95
views
Ruby Application using When/Case yielding Nil when it shouldn't
The following code should print one of the three options given depending on the results of any of the == checks, but it doesn't. It yields nil for any value of your_message provided via gets.chomp. ...
-1
votes
0
answers
19
views
Exhausted all sources trying to fetch version 'latest' of RVM
Ansible appears to be failing when attempting to run the RVM installer. I'm not actually very familiar with Ansible and I've inherited this Vagrant/Ansible configuration so any help much appreciated.
...
0
votes
0
answers
16
views
Override Attributes are not working for my role
My cookbook does this:
# attributes/default.rb
default['fieldone']['fieldtwo'] = [
{'somekey' => 'val1', 'someotherkey' => 'vala'},
{'somekey' => 'val2', 'someotherkey' => 'valb'},
{'...
1
vote
1
answer
39
views
Why won't rbenv or chruby switch to an installed version of Ruby?
I'm trying to get Jekyll running on my Mac M1. This requires a Ruby install. I had everything working a couple days ago, but must have changed something and now I cannot make sense of why it's no ...
-1
votes
0
answers
48
views
How can I shift elements to the right using the each method? [closed]
How can I shift elements to the right using the each method?
a = [1,2,4,8,16,30]
p = a.rotate(-1) a = [30,1,2,4,8,16]
0
votes
0
answers
28
views
How to add horizontal scroll in kanban board that made using jQuery-UI sortable
I created a kanban board using Ruby on Rails and jQuery-ui sortable. In this kanban board user can drag and drop tickets into individual columns according to its status.
Screenshot:
I want vertical ...
0
votes
1
answer
40
views
How to convert Ruby 0.36827e1 to 3.6827
When saving data in a database, it is necessary to process the data. How to convert Ruby 0.36827e1 to 3.6827
I cannot use multiplication directly because the suffix is e1, and I cannot use split to ...
0
votes
1
answer
17
views
How to ignore error report for Honeybadger in Rails app
how to ignore my custom error for Honeybadger in rails app? I just need to raise that error, but don't report it to HB.
I have got my custom error class looks like this:
class RetrySidekiqJobError <...
0
votes
1
answer
51
views
ruby 0.20058343942960624257135598502550788022255447223e2 How to convert to 20
I encountered this error during unit testing, and I tried using to_i. But this is wrong, how should we solve it
--- expected
+++ actual
@@ -1 +1 @@
-0....
1
vote
1
answer
28
views
Error: undefined method `[]' for nil:NilClass (NoMethodError)
I am doing the nand2tetris project in Ruby, and I am programming a translator from VM to Jack.
I keep getting the error:
in initialize': undefined method []' for nil:NilClass (NoMethodError)
path = ...
1
vote
1
answer
61
views
How to find rails route pattern from url
Given a rack request where I know the path, e.g. /things/1, how can I get the route reference e.g. /things/:id?
I can use Rails.application.routes.recognize_path to get the controller and action, but ...
0
votes
0
answers
28
views
ruby, how to not check 2nd statement in case the first one is True during a OR(||) [closed]
Okay, So I have this code:
def teste
puts "has entered here"
1 == 2
end
def some_condition_is_true
1 == 1 || teste
end
puts some_condition_is_true
The way I understand is that it ...
0
votes
1
answer
19
views
Stripe::InvalidRequestError in CheckoutController#create
I am new to Ruby on Rails and I am getting the following error,
You cannot use line_items.amount, line_items.currency, line_items.name, line_items.description, or line_items.images in this API version....
-1
votes
1
answer
20
views
Ruby: Creating a class method that all classes can use [duplicate]
I am trying to create a method that can be called by any class, similar to how .is_a? can be called by any class. How can one go about this?
I have tried using alias_method and Class.send(method) to ...
1
vote
1
answer
63
views
How to link ruby.h to C++ CMake project
I'm currently trying to build a project in Windows (I'm not using Linux to develop it because my final target is my app to be fully usable in Windows) with C++ & CMake that needs to call some ruby ...
0
votes
2
answers
20
views
How do I get ruby gem 'slop' to return an array of filenames after a shell glob
I am trying to get the ruby gem 'slop' to accept a list of files that are being provided through a shell glob. Thus in a directory where I have files foo_1, foo_2, foo_3, I want to pass my_prog -f ...
0
votes
1
answer
14
views
Using Ruby with active record How do I access joined columns?
I am trying to join my Person table to my Address table with the ultimate goal of purging addresses with a pointer to a non-existent person.
Here is my Address model:
class Address < ...
-1
votes
0
answers
23
views
ruby on rails Alert if statement password = @address.password
how can i add specific password to this
class AddressesController < ApplicationController
before_action :authenticate_user!, only: [:new, :create]
http_basic_authenticate_with :name=> User....
0
votes
1
answer
25
views
Rails Session Store + Redis: Can I set TTLS in redis without setting expiration on sessions?
Is there a way to add a TTL to sessions stored in Redis by Active Record Session Store without cookies getting an expiration date to match? I don't want my users' cookies stored and my understanding ...
1
vote
0
answers
20
views
Rails 6 deploy on AWS ECS is breaking with no real error
I recently upgraded an Rails app from ruby 2.2.x to ruby 2.7.7 and rails 5.2 to 6.0.6.1. In the process I updated bundler to 2.4.8. Everything works locally, including the docker build, and all github ...
0
votes
0
answers
14
views
Using the IMGUR API and page result pagination
https://julian-cristman-art.onrender.com/
I'm building an art portfolio for a friend, and using the IMGUR api to allow him to easily upload images to his site. My project is using HTTParty to make ...
-1
votes
0
answers
21
views
Print a string in database from simple form checkboxes
I have 3 propositions i want my user to be able to choose from : Rent, sell or sublet, with simple form collection checkboxes and print the selection into the database.
I did try the following code ...
0
votes
0
answers
10
views
Update select box options within js.erb template - XSS safe and properly display text
I am rendering a .js.erb file within my rails app. Within this file, I'm updating the options for a select box.
The most important thing is that I am doing this in a XSS Safe manner. Given the ...
0
votes
1
answer
21
views
Ubuntu Rails Production server Permission denied
I am running into a issue where my rails server cannot edit files on the server.
I am running spree 4.3.2 and deployed via mina.
I am getting this error as a result
Permission denied @ `...
0
votes
1
answer
35
views
ActionCable.server.broadcast won't broadcast
I am trying to migrate a rails application from using Pusher to ActionCable.
In the server side code this is the ActionCable Channel:
class PagesChannel < ApplicationCable::Channel
def ...
0
votes
1
answer
27
views
Can OpenSSL::PKey::RSA object instance be shared between Ruby threads?
Is it ok to share OpenSSL::PKey::RSA object instance between multiple threads (i.e. by assigning it to a constant), or should each Ruby thread use a separate instance of OpenSSL::PKey::RSA object?
0
votes
2
answers
57
views
Ruby grouping hash
people = [
{ "name" => "Mary", "sport" => "squash", "fruit" => "blackberry" },
{ "name" => "Lauren", &...
1
vote
1
answer
46
views
Does Ruby guarantee that eval(str.inspect) == str?
I recently found myself needing to generate a simple Ruby script based on user input, some of which needs to be included in the script as a string literal. While in my specific case this input comes ...
2
votes
1
answer
25
views
String concatenation in a ruby block
I'm trying to understand why the same concatenation operation builds a string in a normal context, but builds an array when run in an each block.
For example, this concatenation works as expected
irb(...
0
votes
0
answers
34
views
ruby: Getting SIGBUS on a simple IO.popen loop?
I have a simple 'system()' like utility method I use to run other programs, and the important bit is here:
File.open(args[:out], 'w') { |outfile|
IO.popen(cmd) { |cmdout|
...