won't block in Ruby

I have the following code for a simple TCP server in Ruby: # server.rb require 'socket' class Server def initialize(port) @port = port end def run Socket.tcp_server_loop(@port) do |connection| do loop do ...
more »

2017-11-11 19:11 (1) Answers

Rails: Change next_page class of will_paginate gem

Is possible to change the class name 'next_page' of will paginate gem? For example is easy to change .paginate class, but I don't know if is possibile with 'next_page' :class - CSS class name for the generated DIV (default: "pagination") :previous_l...
more »

2017-11-11 08:11 (1) Answers

Optimization of simple algorithm

I have this problem: Given the lengths of laps run by two joggers (at the same speed), return the #number of laps. Each must run before they arrive at the starting point at the same #time. and this code: def nbr_of_laps(x, y) result = [] l...
more »

2017-11-11 05:11 (1) Answers

Ruby on Rails Install Error

New to Ruby trying to install devkit to get Ruby on Rails ran into an error when installing Ruby on Rails. Using version 2.4.2 of Ruby and 2.7.2 of Gem. Error is failed to build gen native extension (see image for full console response) Cmd Line Er...
more »

2017-11-11 00:11 (0) Answers

Can't Find ffi.h When Installing ffi ruby gem

Ruby version 2.2.4p230 RubyGem version 2.7.2 Ruby-devel and lib64ffi-devel installed. 64-bit OpenMandriva 3.0, urpmi and rpmdrake used. Goal: to install compass, but the gem ffi is needed first. I have scoured the internet so hard for the last t...
more »

2017-11-10 21:11 (0) Answers

Refine gem's class method

I have to wrap some behavior around an external gem in a elegant and isolated manner. Given the abstraction below, everything runs smoothly, but 'bar' is never printed. Could someone tell me why? My code: module RefineGem refine GemMainModule::G...
more »

2017-11-10 13:11 (1) Answers

Debugging sidekiq worker memory leak with jemalloc

So, I've got a memory leak in my Sidekiq worker. I have a worker server with one queue for this worker task only, that gets to about 10G RSS in a week. I tried to reproduce it locally with only 1 worker thread and voila - I get from 200M to 1G in on...
more »

2017-11-10 11:11 (0) Answers

Rails: Loop thru two different models

I have implemented a basic search and I'm looping thru the results like this: views/items/search.html.erb <% if @items.present? %> <% if @items %> <% @items.each do |item| %> <%= link_to item.title...
more »

2017-11-10 11:11 (1) Answers

Paperclip upload and showing the image not working

I installed paperclip -> 5.1 and latest ImageMagick on Windows 7(yeah..i know) running Ruby 2.3.3 and Rails 5.1.4. I installed file.exe as suggested by paperclip instructions and added 'C:\Program Files (x86)\GnuWin32\bin' to my PATH. When i upload...
more »

2017-11-09 19:11 (1) Answers

Ruby - get method params names and values

Is there a way to get method parameters names and values dynamically, maybe a metaprogramming? def my_method(name, age) # some code that solves this issue end my_method('John', 22) # => { name: 'John', age: 22 } I want to use this in all my ...
more »

2017-11-09 14:11 (1) Answers

From external Web page to HTML stored in db

(Rails 5 + PostGreSQL) I need to read the content of a website, and save HTML of a part of this page. For example, let's say I want to get only the description of an athlete on this page : : the section.text-cont...
more »

2017-11-09 10:11 (2) Answers

NoMethodError in Spree::Admin::Reviews#index

I am new to spree and ruby on rails.While clicking the 'reviews' in spree back-end, it's throwing an error. Thanks in Advance. NoMethodError in Spree::Admin::Reviews#index Showing - var/lib/gems/2.3.0/ruby/2.3.0/bundler/gems/spree_reviews-e51cae96...
more »

2017-11-09 09:11 (1) Answers

|| in Ruby - Unexpected Keyword End

I figure I am missing something trivial but for some reason this code doesn't work and gives an unexpected keyword end error: if "test" || "test2" email = "" else email = @quote.user.emai...
more »

2017-11-08 19:11 (1) Answers

Custom gem not loading into rails app

I've pushed gem into github & rubygems, but constants of that gem are not being loaded into rails app. Tried this by loading from multiple sources and results are like this: rubygems = not loaded github = not loaded local path = loaded Intere...
more »

2017-11-08 18:11 (1) Answers

Includes with a related element

I would like to use the includes method with the related element of my Post My Post can be associated with different type of element. And I use a value :cat to knows witch kind of element is associated. The value work as this (cat: (1 => Message, ...
more »

2017-11-08 15:11 (3) Answers

Assets pipeline rails Heroku

Recently I upgraded my project to Rails 5 and I'm going crazy with the assets pipeline when trying to upload everything to Heroku. The issue is the following: I have a collection of Ejercicios and, when u click on one of them, the app should show it...
more »

2017-11-08 13:11 (1) Answers