Passing information from 'before' to 'after' block
(I'm using JRuby, but I think that my problem applies to MRI Ruby as well)My RSpec definition has this overall structure:RSpec.describe 'XXX' do before(:all) do # preparation common for each example...
View ArticleNokogiri installation error and fails with mac os x 14 Sonova
I am trying to install an older version of nokogiri (1.6.8.1) on a x86 intel mac using sonova 14.4 with a ruby project of mine but i am experiencing a problem with either bundle install or gem install...
View ArticleHow does String.crypt generate the same hash as BCrypt when given the BCrypt...
I found some code that uses String.crypt to hash passwords (yikes!), so I played around with a way that I could check a password against a BCrypt hash as well as the old String.crypt hashes.What I...
View ArticleReccive Gateway Events Discordrb
How can I reccive gateway events and do something when for example the channel pins are updated using discordrb? https://discord.com/developers/docs/topics/gateway-events#receive-eventsI'm guessing I'd...
View ArticleShopify REST API adjusting InventoryLevel doesn't works
I am building an job that interacts with Shopify API with shopify-api-ruby gem, here the test code:LOCATION_ID = '61167763535'VARIANT_ID = '41932294357071'variant = ShopifyAPI::Variant.find(id:...
View ArticleRails + Ranscaker, How to hide empty params in url
I have created search forms using Ransack, but I have a problem. When I leave input empty I would like form not to send these inputs, so it won't appear in my parameters.Right now when i leave filters...
View ArticleRunning an application's commands, like rake, from a standalone ruby script...
I am on Ubuntu 18.04.I have a Rack-based application at /home/jignesh/webapps/my-app-1 (henceforth this will be referred to as app_root).app_root contains following...
View ArticleRuby create JSON from SQL Server
I am trying to create JSON in Ruby from data coming from a SQL Server table, based off a query. I've worked with Ruby quite a bit and JSON some. But never together.This is a sample of the JSON I'm...
View ArticleHow do instance variables in rspec work?
Here is a bit of code from M Hartl's Ruby on Rails Tutorial. Can anyone explain why an instance variable (@user) is necessary and why not use a local variable. Also, since instance variables are...
View ArticleSolution/Architecture: queues or something else?
I have a multiple frontends to my service written in Node.js and workers written in Ruby. Now the question is how to make those communicate? I need to maintain dynamic pool of workers to handle load...
View ArticleValidate if a string matches a format string
In Ruby, you can parse a string into a DateTime based on a given format string, for example:3.2.4 :001 > DateTime.strptime(Time.now.to_s, '%Y-%m-%d %H:%M')Sat, 17 Aug 2024 13:31:00 +00003.2.4 :002...
View ArticleHow to make distributable ruby binary exe? [closed]
How can i make a distributable binary exe with GUI? I have some ruby scripts that i want to package in exe to distribute,
View ArticleManipulating Output from an Array of Nested Hashes in Ruby
I've been pulling data from an API in JSON, and am currently stumbling over an elmementary problem The data is on companies, like Google and Facebook, and is in an array or hashes, like so: [...
View ArticleWhat does the "yield" keyword do in Ruby?
I encountered the following Ruby code:class MyClass attr_accessor :items ... def each @items.each{|item| yield item} end ...endWhat does the each method do? In particular, I don't understand what yield...
View ArticleWhat is the difference between pluck and collect in Rails?
Here are two sample codes.First one with collect:User.first.gifts.collect(&:id)Second one with pluck:User.first.gifts.pluck(:id)Is there any difference between them in performance or something else?
View Articlerb-sys Failed to build on Windows latest: defines.h:43:11: fatal error:...
I have a Tauri project and got a compilation error on Windows's latest runner on GitHub action:error: failed to run custom build command for `rb-sys v0.9.100`Caused by: process didn't exit...
View ArticleError when using rails command "rake db:create:all" - I think its related to...
I created a new Rails API app. I am trying to create the database table for the app with the command for a postgres db rake db:create:alland Im getting this error:...
View Articleblock sees self as the object it is sent to
I have the following code for connecting to websocketsclass Connection < AbstractConnection def initialize @conn = WebSocket::Client::Simple.connect @url @conn.on :message do |event| puts 'received...
View ArticleHow to display Datatable tabletools (copy, csv, excel, pdf, save) in ruby on...
I am using Datatable in my ruby on rails application. I follow the same one which is here..https://github.com/rweng/jquery-datatables-railsAnd My datatable sorting and searching working properly. But I...
View ArticleUnable to write files to AWS Lambda Ruby tmp directory
I've had a Ruby 3.3 AWS Lambda function recently stop working sometime in the last couple of weeks. It seems that the function can no longer write to the tmp directory if the file size been added is...
View Article