Category "ruby"

Gem::Ext::BuildError: ERROR: Failed to build gem native extension - rbnacl-libsodium 1.0.16

I was trying bundle install and my gem file has gem 'rbnacl-libsodium' it took some time for installation and got failed. Using rbnacl 4.0.2 Fetching rbnacl-lib

rails tutorial Test errors that occur after Chapter 6

I'm a beginner. rails tutorial I got an error like this when I did a rails test after finishing Chapter 6 and before giving it to git. I did an integration test

How do I open ruby file in irb?

I'm currently using AWS cloud 9. I want to run my code but when I use the ruby command to open up my ruby file in irb it sometimes works or it gives me the erro

Array and string in ruby

Hi amazing stackers! date = "10/02/2021" d1 = date.split("/") d2 = d1.to_s puts d1 puts d1.class puts d2 puts d2.class in the above code, d2 shows the data typ

getting most liked posts by users using act as votable gem rails

I want to display the top 10 users whose posts got the most likes in past 2 hours, how can I do that inquest index to get user <%@users.each do |user| %>

Rails 7.0.4 Error when in run some code of ruby on rails

no implicit conversion of Hash into String class PostsController < ApplicationController @posts = Post.all respond_to do |format| format.html forma

Return Elements in the array that start with a specific letter e.g D

I am having issue with my code below. I am new to ruby. I want to return names that only start with the letter D but it just returns all the names. When I try t

Is there a way to keep the order of cases as defined, while running bundle exec rspec {file_path} --format documentation?

I am having a problem while running bundle exec rspec spec/services/abc_service_spec.rb --format documentation The output of it, is not in the same order as th

How to reduce the number of tracking records when saving on keystroke?

When saving changes to a model in rails, two popular gems to track changes are paper_trail and audited. These gems create records that contain versioning inform

How to mock module static method in ruby rspec?

I am trying to write some rspec tests and I want to mock a static method from a module. The setup is like this: module MyModule def self.my_method 'end' en

Rails ActiveStorage Variants url

I'm trying to create an api to get a model's original image and other variants. Right now I'm not storing attachments on external storage, but I plan to save th

Is there an equivalent tool like ruby-prof for node.js?

I want to profile a Jest test, but I only want to see the behavior for some specific methods. In ruby, I can do that with ruby-prof, but is there an equivalent

Ruby: Libusb, one USB Device, two input endpoints = difficulties

I'd like to read out an USB Device in Ruby with libusb, which has two endpoints for input, once 0x81, which is in fact a Midi input Connector, and 0x82, which i

Write a program that adds together all the integers from `1` to `250` (inclusive) and `puts`es the total

How would I do this using ruby and only using a while loop with if, elsif and else only?

Ruby on Rails routes - Query parameter vs id

I'm trying to set a route that accepts a dynamic field. Restaurants have categories [:chinese, :fast_food, :french, :vegan] and the route restaurants/vegan allo

Flash is not displayed in the same view in Rails

I need to display flash in the same view (:edit) after successfully updating an object. If I redirect to another action - everything works correctly. But when I

Detect if block is given in Ruby define_method block

When searching, keywords 'block' and ruby 'define_method' keep telling me to explicitly define + call the block. Tried a bunch of stuff, including looking at so

How can I write this in haml? (rails app)

<a href="/"> <i class="material-icons">file_download</i> Export to CSV </a> I am using a material_icon gem. "file_download" is a do

Modify updated_at attribute through db trigger in rails

I was wondering if there is anything wrong about updating the updated_at attribute of a record through a db trigger in terms of fragment caching (i.e. the parti

How to ensure I can't add in integers or any numbers into an array via user input for ruby

I'm trying to create an array that only allows strings to be passed through, no numbers at all. Is there a way to make this possible? I've tried the below expec