Regex / Ruby - split keeping delimiter
I need to split a string containing variables/delimiters, something like;"Hello %Customer Name% your order number is %Order Number% and will be delivered soon"Using;string.split(/%/)=> ["Hello ",...
View ArticleSplit on regex (more than a character, maybe variable width) and keep the...
In GNU awk, there is a four argument version of split that can optionally keep all the separators from the split in a second array. This is useful if you want to reconstruct a select subset of columns...
View ArticleCMS for ecommerce website in rails
Are there any CMS available in rails which we can extends as per need for ecommerce website ?
View ArticleHow to fix "no implicit conversion of String into Hash"
I am trying to run a test with RSpec but it always returns the same error:DevicesController#update when user is a manager must update any device Failure/Error: put device_path device_id, params:...
View ArticlePassing values between cucumber statements
I'm running in to an issue in that I need to get one value in a cucumber statement, and then give that value to another statement. Specifically I am getting a JSON object from one page (where that...
View ArticleUpgrade or Rewrite Ruby on Rails App (Rails 5.0 to 7.1)
Upgrade or Rewrite Ruby on Rails App (Rails 5.0 to 7.1)Hi, i got a Large Webapp (A Shop with user management, Orders and so on, and a ThreeJS App, which communicates with the ROR app over api...
View ArticleUnable to properly start Sorbet VSCode Extension
I need to run Sorbet VSCode extension in order to enable the static type check inside the IDE.Everything has been setted up following the offical doc and I managed to properly run this extension on a...
View ArticleRuby AWS SDK secretsmanager 'undefined method `[]' for nil:NilClass...
I'm trying to use the AWS SecretsManager SDK in Ruby and I'm getting the following error:.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/aws-sdk-core-3.186.0/lib/aws-sdk-core/ini_parser.rb:28:in `block...
View ArticleConvert Array of objects to Hash with a field as the key
I have an Array of objects:[ #<User id: 1, name: "Kostas">, #<User id: 2, name: "Moufa">, ...]And I want to convert this into an Hash with the id as the keys and the objects as the values....
View ArticleHow to install PostgreSQL's pg gem on Ubuntu?
I'm trying to install PostgreSQL's pg gem for Ruby.I issued the following command:gem install pgI installed Ruby 1.9.2 using RVM.The above command shows me the following error.The error is :Building...
View ArticleRuby CSV - get current line/row number
I'm trying to work out how to get the current line/row number from Ruby CSV. This is my code:options = {:encoding => 'UTF-8', :skip_blanks => true}CSV.foreach("data.csv", options, ) do |row, i|...
View ArticleWSL brew update error - cannot load file fiddle
I just installed Homebrew on my linux subsystem and it wouldn't allow me to update it. Any idea why this might have happened? Homebrew version is 4.3.22 now, but i want to be able to solve this for the...
View ArticleSyntax error when rails tries to create ar_internal_metadata?
after upgrating from rails 5.2 to rails 6.1 and ruby 2.7.2 to 3.3.5 I'm facing some weird errors syntax errors when running the initial migration. The application runs fine and even run the migrations...
View ArticleIn Ruby, how to count the number of instances created (including subclasses)?
The following class Point contains a class instance variable @count that counts the number of instances created. It seems to work fine:class Point @count = 0 class << self attr_accessor :count...
View ArticleApp not starting with cryptic Passenger log error
I have a Rails app set up with Passenger + Nginx.When trying to access the app I get the following error in passenger's logs:/home/my_user/.rbenv/versions/3.3.1/bin/ruby: No such file or directory --...
View ArticleRuby turn values inside a hash into local variables
Say I have this hash:entry = {"director"=>"Chris Nolan", "producer"=>"Sum Duk", "writer"=>"Saad Bakk"}I want to extract each key into its own local variable with the associated value:director...
View ArticleRuby: transform Hash-Keys
I have a Hash:urls = [{'logs' => 'foo'},{'notifications' => 'bar'}]The goal is to add a prefix to the keys:urls = [{'example.com/logs' => 'foo'},{'example.com/notifications' => 'bar'}]My...
View ArticleIn Rails Administrate, how to change search bar from "like" to "equal"?
I use https://github.com/thoughtbot/administrate to create my dashboard pageThis is my attributes types ATTRIBUTE_TYPES = { user_id: Field::Number.with_options(searchable: true), id: Field::Number,...
View ArticleHow to Translate Ruby Tag Subset Filtering into Elasticsearch Query?
I have a Ruby code snippet where I filter news articles based on whether the user’s tags contain all the tags of the news article. This is done using Ruby's select method after fetching the data from...
View ArticleCan we connect active storage in Ruby On Rails with Azure using Managed...
I have gone through this article:- https://hix.dev/tutorials/ruby-on-rails/active-storage#azure-rails-configurationConfiguration on rails sideazure: service: AzureStorage storage_account_name: <%=...
View Article