Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Browsing all 4609 articles
Browse latest View live
↧

Rails - how to "generate" statistics from hundreds of thousands of data in...

I have a model Item with the corresponding database table items where is currently about 240,000 records.I need to generate statistics from the data in the items table on my dashboard. Currently, I am...

View Article


incompatible character encodings: UTF-8 and ASCII-8BIT in render action

ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT): app/controllers/posts_controller.rb:27:in `new' # GET /posts/new def new if params[:post] @post =...

View Article


How to calculate reorder quantity based on current stock, lead time and...

I'm running into an issue with my code where I can't seem to accurately calculate the reorder quantity of my inventory and need some help brainstorming possible solutions. I'm taking data from a CSV...

View Article

Brew Ruby formula with multiple source files

In a single Ruby formula vedic.rb I want to link multiple files. It builds from source with: "brew install --build-from-source vedic.rb" but gives error wrong constant name, and that it's unrecognised...

View Article

Upgrading Global Ruby Version on macOS

I am trying to update Ruby on my computer to version 2.7.0 as that is the latest stable version.Running macOS Catalina Version 10.15.3Have tried the top two solutions from this StackOverflow post.1....

View Article


Problematic caching with rack cache

I am trying to cache a response from a server locally per example shown here.#!/usr/bin/env rubyrequire 'restclient/components'require 'rack/cache'RestClient.enable Rack::Cache, :metastore =>...

View Article

Rake task return value for Ruby system() call

I have a Rake task which looks something like the following. What I’m trying to do run a system command, and return its error-value. Before returning I’d like to display a message saying something like...

View Article

What is the Ruby equivalent of Python Dataclasses?

What is the counterpart for the Python Dataclass exist in Ruby?In Python it is possible to use dataclasses to tersely define a class without explicitly defining an initialiser / __init__ method for...

View Article


Paginating Filtered Tables in Turbo Frame using Pagy?

I'm trying to implement pagination in my Rails project using the Pagy gem. I have a Record Model and index view for displaying my Records in a element and a form above the table to filter the table...

View Article


Single executable binary of Ruby gem

What options are available to create a single binary that contains my Ruby gem along with a Ruby runtime?My goal is to be able to share the executable with another developer and they could simply run...

View Article

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.Failure/Error: require...

View Article

Why are ruby fibers instantaneous when I set my silly scheduler?

I'm trying to understand (and accomplish) "interweaving" concurrency using ruby Fibers. To do that - I tried to implement my own scheduler but I hit a roadblock.Here's the code to test:f1 = Fiber.new...

View Article

I am trying to setup rails application with mysql as a database but getting...

Gem Load Error is: Incorrect MySQL client library version! This gem was compiled for 10.8.8 but the client library is 3.3.8.Although i have latest version of mysql

View Article


Rails : RuntimeError - can't modify frozen Array when running rspec in rails

I recently upgraded to Rails 5.1 from v4.3 and am now getting this error when running tests:An error occurred while loading ./spec/controllers/admin/capacity_charges_controller_spec.rb.Failure/Error:...

View Article

Rails 6: Zeitwerk::NameError doesn't load class from module

I have a file which looks like this#app/services/account/authenticate/base.rbmodule Account module Authenticate AuthenticateError = Class.new(StandardError) class Base < ::Account::Base def...

View Article


Equivalent of "continue" in Ruby

In C and many other languages, there is a continue keyword that, when used inside of a loop, jumps to the next iteration of the loop. Is there any equivalent of this continue keyword in Ruby?

View Article

most efficient way to write data into a file

I want to write 2TB data into one file, in the future it might be a petabyte.The data is composed of all '1'. For example, 2TB data consisting of "1111111111111......11111" (each byte is represented by...

View Article


What is the use of assert_predicate in MiniTest?

I have a problem understanding the usefulness of assert_predicate in MiniTest. How is it different from assert_equal? When would one want to use this assertion? I have came across it many times but did...

View Article

Fibonacci sequence in Ruby (recursion)

I'm trying to implement the following function, but it keeps giving me the stack level too deep (SystemStackError) error.Any ideas what the problem might be ?def fibonacci( n ) [ n ] if ( 0..1...

View Article

How to handle exceptions with Ruby Rest-Client

I recently switched from Ruby's Net:HTTP class to rest-client 1.6.7.I find it a lot easier to form requests, but unlike Net:HTTP request, when rest-client gets anything other than a 200, the request...

View Article
Browsing all 4609 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>