Populate non ascii password in a file using puppet
I am trying to populate a password with non ascii characters into a template file using puppet. I have ecoded password with non ascii to base64 and placed it in hiera-esecrets. When I try to decode the...
View ArticleHow to use bound function as Proc in Ruby [duplicate]
I'm new to ruby, and I'm trying to read a simple CSV file.I can do thisFile.read("info.csv") .split[1..] .map {|it|it.split(",")}But I'd like to know if there's something like this to replace the last...
View ArticleWhat is the best way to hide module method in ruby?
In JavaScript, it's easy to hide function or variable in closure.In ruby, private doesn't work for Module method.Is there best practice to do so? module Lib def self.public_function private_function...
View ArticleHow to find a hash in array of hashes by certain value and if not found then...
Is there a nice Rails way to implement the following:I have an array of hashes:my_obj = [ { gid: 'gid1', name: 'name1', age: 'age1' }, { gid: 'gid2', name: 'name2', age: 'age2' }, ...]I need to find an...
View ArticleWhy is String#split("\n") and Array#join('') quicker than String#gsub(/\n/, '')?
I have to remove all newlines from a large number of strings. In benchmarking string.join("\n").split('') vs string.gsub(/\n/, ''), I found that the split and join methods are much quicker, but have a...
View ArticleIs it possible to navigate from feature file to step definition in VSCode
I am primarily using RubyMine for Cucumber/Ruby, and now, I'm getting my hands on VSCode, with which I'm able to run and debug test cases. I can't find a way to navigate from feature to step...
View ArticleMaking sense of Ruby server on Cpanel
I have set up a Ruby 3.2 app with cPanel on a hosted system.The rubyhome directory is ruby.myDomain.co.uk. It contains config.ru and app.rb and no html files.A subdirectory of rubyhome is /public which...
View ArticleHow we can use Like queries for searching on encrypted data? I used default...
My Propose model is below for in which i use Active Record Encryption to encrypt some fields and I'm fetching the data using LIKE query as added below instead if rails query, but when i call that scope...
View ArticleTurn VCR off for Specific Specs
How can I tell VCR that I want it to completely ignore a spec file?I've read a post on Google Groups that suggests either allowing real HTTP requests, or turning VCR off explicitly.What would be much...
View ArticleHow to make mobility translations ransack searchable in active admin?
I have a rails Product model with mobility translation attribute.When I try to add it to admin panel I get the error:Ransack needs Mobility::Backends::ActiveRecord::KeyValue::StringTranslation...
View ArticleDetect that code run by RSpec, Ruby
I would like to be able to know that my code is run under rspec or not. Is this possible?The reason is that I am loading some error loggers that would be cluttered with deliberate errors (expect{x}.to...
View ArticleHandling Conditional `belongs_to` Associations with Different Foreign Key...
I'm working on a Rails application where I need to manage a polymorphic association with different types of foreign keys based on the reporter_type attribute. The main challenge is that the foreign key...
View ArticleHow to fetch topics using karafka
I need to do health check using karafka.We have multiple services so for supporting this feature we have a separate repo rails-helper.previously we used to do health check using kafka but there is...
View Articleproblem with bundler not installing gems for different platforms
I use a Mac locally and in my Gemfile.lock, I have both platforms:PLATFORMS arm64-darwin-23 x86_64-linuxso when I bundle install I get nokogiri-1.16.7-arm64-darwin.gem in my Rails app's vendor/cache....
View ArticleIs there any way to parse JSON with trailing commas in Ruby?
I'm currently coding a transition from a system that used hand-crafted JSON files to one that can automatically generate the JSON files. The old system works; the new system works; what I need to do is...
View Articlehow to get source code of a ruby proc/lambda [duplicate]
e.g. i'm trying to do this:Benchmark.ips(-> { add }, -> { sub })currently i'm doing:def Benchmark.ips(*reports, &block) if reports.any? super() do |x| reports.each do |report|...
View ArticleIncorrect MySQL client library version on windows ruby
I'm on ruby, running on a windows.The gemfile has this gem :gem 'mysql2', '~> 0.5.5'Whenever i'm try to do a rails command, I have this error`rescue in block (2 levels) in require': There was an...
View Articleajax-datatables-rails how to use view_columns with one class associated twice
I use this gem for datatables in rails and have problem working with one Model associated twicehttps://github.com/jbox-web/ajax-datatables-railsthis is my modelclass Associate < ActiveRecord::Base...
View ArticleBundle install errors and cannot continue, even after installing missing gems
I am working on multiple Ruby on Rails applications and running...MacOS 10.15.7,Ruby 2.6.5,Rails 5.2.3,In a project app directory I am trying to run a bundle install and get the following error:An...
View ArticleHow to redefine a Ruby constant without warning?
I'm running some Ruby code which evals a Ruby file every time its date changes. In the file, I have constant definitions, likeTau = 2 * Piand, of course, they make the interpreter display the unwanted...
View Article