Category "ruby"

Error while creating project on ruby on rails

I am new to ruby on rails hence when i am trying to create new project by following command: rails new abc I am getting following error rails aborted! Psych::Ba

Active Admin login not working (Devise + ActiveAdmin + Devise JWT)

I'm using rails in API mode, with Devise and Devise JWT (for the API), and ActiveAdmin. I had everything working but I've been building out the API controllers

How to generate correct Fragment identifier in Jekyll/Kramdown?

I'am using Jekyll with the Minimal Mistakes template and facing a problem with the fragment header generation. Here is an example.. If you put a header into you

React-rails Cannot Find App Component in View

Finally after many steps of troubleshooting rails is rendering our NavBar component, but not the base App component where everything is imported. Wondering what

Mongo::Error::UnsupportedFeatures (Server at (localhost:27017) reports wire version (2), but this version of the Ruby driver requires at least (6).)

I'm trying to upgrade Mongoid in an Rails 4.2 app from 4.x to 5.x (5.4.1) to connect to a MongoDB 2.6. I've updated the mongoid.yml file to match the difference

Is Ruby on Rails getting started guide up to date?

I'm trying to learn ruby on rails from the official website guide, and I copy paste almost all code but some seems not working. like this on for exemple, I get

Rails gem strong_migrations preventing schema from loading

I've recently tried added the strong_migrations gem to my project, but it's preventing me from running any tests because all of the tables in my schema have the

Rails 7 Ruby 3.1 LoadError: cannot load such file -- net/smtp

I upgraded to Rails 7 and Ruby 3.1. While trying to run tests with rspec I got the error below. How can I fix it? An error occurred while loading rails_helper.

Spliting a table column in 2

I have a this column : t.geography "longlat", limit: {:srid=>4326, :type=>"st_point", :geographic=>true} So basically im trying to work with postgis m

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