/usr/local/rvm/rubies/ruby-3.2.1/bin/ruby: No such file or directory --...
I have setup Passenger/NGINX server for my rails application on a VPS.Strangely Passenger cant see the ruby path even though it is clearly configured passenger_ruby...
View Articleruby : return object if test is true
I'm looking for a function that would do the following:def self.my_find object = self.first #Whatever return object.my_check? ? object : nilendSomething like check:object.check(&:my_check?)It...
View ArticleHow to alias a class method in rails model?
I want to alias a class method on one of my Rails models. def self.sub_agent id = SubAgentStatus.where(name: "active").first.id where(type: "SubAgent",sub_agent_status_id: id).order(:first_name) endIf...
View ArticleUnit testing with rspec2 and Nokogiri
I have a requirement to read a third-party public website. Currently I am able to do this via Nokogiri, but I'm having trouble writing some unit tests using rspec.I have this HTML <div>:<div...
View ArticleHow is it that Ruby methods requiring blocks can just use Procs instead?
I am learning Ruby and was looking at the documentation of Array#maphere, and it says the the syntax is as followsmap {|element| ... } → new_arraymap → new_enumeratorBut we are able to do...
View ArticleCocoaPods and Ruby Compatibility Issues with Flutter 2.6 on M1 Mac (Pod...
I have a Flutter project from 2021 that I need to rebuild without upgrading dependencies. To manage different Flutter versions, I installed FVM and switched to Flutter 2.6 to build for iOS.However,...
View ArticleRuby getting the diagonal elements in a 2d Array
I was trying some problems with my 2D ruby array and my LOC reduces a lot when I do array slicing. So for example,require "test/unit"class LibraryTest < Test::Unit::TestCase def test_box array =...
View Articleruby on rails add a column after a specific column name
I tried to add a column to a table after a specific column in the table.Here is what I did:rails generate migration add_reaction_id_to_patient_allergies reaction_id: integer :after =>...
View Articlebundler: failed to load command: fastlane (/usr/local/bin/fastlane) in ubuntu...
I am using this command to install fastlane in GitHub Actions in Ubuntu image: - name: Bundle install run: | cd ./android curl -sSL https://rvm.io/mpapis.asc | gpg --import - curl -sSL...
View ArticleHow do I get a list of required fields in a model in Rails?
I am using Ruby on Rails and I have a model with many different required fields. Is there a way to retrieve a list of only the fields that are required? I don't believe ModelName.validators works...
View ArticleHow do I use rugged to add and commit all files in a repository
I am initializing a git repository that already has some files in itrepo = Rugged::Repository.init_at(".")I need to stage the files already in that folder and commit them. This is what I've tried:repo...
View ArticleCompile ruby script for faster use
I have a ruby script of around 2200 lines which is being used repeatedly, so is there a way to convert it into binary or compile it so it runs faster.
View ArticleReplace NULL with NIL when using JSON or Hash
I have the following JSON and I'm trying to replace null with nil because ruby can't compile it.I get the following error undefined local variable or method "null" for main:Object...
View ArticleHow to delete a folder in s3?
I have the following hierarchy in my s3 bucketbucket_name/folder1/folder2/file1bucket_name/folder1/folder2/file1I am able to delete all the files within folder2, but that leaves the bucket with empty...
View ArticleHow to create a string constant in a ruby block [closed]
I'm trying to create a Proc to pass to a method to find a key in a hash.I'm checking to see if the key, "Open" exists:title = "Open"block = Proc.new { |key, val| key == "'#{title}'" }def...
View ArticleAn error occurred while installing psych (5.1.2), and Bundler cannot continue
An error occurred while installing psych (5.1.2), and Bundler cannot continue.In Gemfile: debug was resolved to 1.9.2, which depends on irb was resolved to 1.13.1, which depends on rdoc was resolved to...
View ArticleUnable to install posix-spawn
I installed the Xcode 4.6.2 Command Line Tools via Xcode > Preferences > Downloads > Components > Command Line Tools, and its status is "Installed", yet after restarting my mac, running on...
View ArticleIs there a way to take a screenshot when before of after :context hook fails...
I've implemented screenshot capturing for my project using rspec/capybara. But capturing works only in case test fails in 'it' block. Using before/after/around hooks from spec_config is not a solution...
View ArticleWhy are exclamation marks used in Ruby methods?
In Ruby some methods have a question mark (?) that ask a question like include? that ask if the object in question is included, this then returns a true/false.But why do some methods have exclamation...
View ArticleWhat's the difference between passing an argument and passing a block in Ruby?
I am trying to understand how this piece of ruby works. (Please forgive me if it's been asked before but I could not find anything here or on ruby-lang.org documents.)The code is:some_method do # lines...
View Article