Questions tagged [ruby]

Ruby is a multi-platform open-source, dynamic object-oriented interpreted language. The [ruby] tag is for questions related to the Ruby language, including its syntax and its libraries. Ruby on Rails questions should be tagged with [ruby-on-rails].

ruby
Filter by
Sorted by
Tagged with
2 votes
2 answers
1k views

Rails - how to correctly implement a payment/booking process

I'm building an events app in rails and I'm using Stripe to collect my payments. It took me a while but I've got payments working. However, when I try and increase the quantity of spaces to book, the ...
Mike.Whitehead's user avatar
2 votes
1 answer
100 views

Partial Pivoting in PostgreSQL or Rails

Assume I have 3 tables, and I can't change any DDL Class id: integer name: string and Student id: integer name: string class_id: integer //Foreign key to Class table and Score id: integer ...
Kuzunoha's user avatar
  • 175
1 vote
1 answer
107 views

Access two tables inside tr tag of an outer table, which in turn contains tables and other elements like select list, text area

My need is to identify the table and check the values of each select list for particular Problem name and their corresponding notes values. Here I found that the question itself got split into two ...
irs102info's user avatar
2 votes
3 answers
4k views

Ruby slim inline if

I'm trying to do an inline if with Ruby Slim. Given my example below... - if @droppable .panel data-draggable="true" span More content here - else .panel span More content here In both ...
Mobidi's user avatar
  • 95
0 votes
0 answers
550 views

how to pause/resume of file during uploading on server in rails

i want to make a resume able video up loader in rails . what is the best way to make this .should i use to fineuploadr , or jquery-file-uploader. is it possibale with paperclip gem ruby or not ? I ...
Ali Raza's user avatar
1 vote
2 answers
561 views

Get set of hashes from array of hashes between two date values

I have an array of hashes that contains a date and total key. For example: hash = [{ "Date"=>"01/01/2016", "Total"=>10 },{ "Date"=>"02/01/2016", "Total"=>20 },{ "Date"=>"03/...
Cameron's user avatar
  • 28.5k
1 vote
1 answer
329 views

Quickbook Create invoice error in rails

i am getting this error when i am creating invoice using Quickbook rails gem (quickbooks-ruby) Quickbooks::IntuitRequestException (Required param missing, need to supply the required value for the ...
vipin's user avatar
  • 2,482
0 votes
1 answer
102 views

Custom gemset RVM

I want to create my own gemset for my application. Gems installed and using from local dir(app/vendor/bundle/...) When I try to execute: rvm gemset create myapp it's creating new gemset. But how I ...
Eugene's user avatar
  • 689
-1 votes
1 answer
34 views

Ruby On Rails - Order By external column count

I have table rooms and table contributor. On Ruby on Rails : How order rooms depending on the number of contributors (conributor.room_id == room.id)?
Charles Bourrée's user avatar
0 votes
1 answer
60 views

Getting a huge list of files in ruby

I'm trying do some operations on a directory which contains nearly 20 million files, I tried Dir.glob, Dir.foreach and Dir.entries to no success. Is there anything similar to Csharp's Directory....
Jeremy Mc's user avatar
  • 119
1 vote
1 answer
2k views

Rails Rspec test with carrierwave image

I wrote an API which can return latest 5 Newsletter and its image, but I am stuck at writing its rspec test. First of all, here is the relationship between model. Newsletter has_many ...
rj487's user avatar
  • 4,604
0 votes
2 answers
46 views

HTML - ruby form action and URL redirection issue

I am using rails at the back end and html for in the front end with angular js. I have an HTML email and this form is present inside the email. I want the user to input his contact and submit the ...
Savvy's user avatar
  • 21
2 votes
3 answers
1k views

ruby Compare values between hashes in different arrays

I have two different arrays, each consisting of different hashes. new_array1 = [ {:index=>4, :column=>0, :ID=>"ABC"}, {:index=>4, :column=>1,...
danynl's user avatar
  • 299
0 votes
1 answer
10k views

undefined local variables or method for main: Object <NameError> For Ruby

I'm getting this error message that says rb:10:in 'activities': undefined local variable or method 'beach_bum' for main:Object I'm calling the method/function by typing in activities, I'm not sure ...
Nathan Vu's user avatar
4 votes
1 answer
525 views

Rails 5 - how to use Pundit

I've had a long break from my 2 years of effort in trying to learn how to use pundit in my rails app. I'm back and trying to learn how to use pundit. I've made a completely new rails 5 app and ...
Mel's user avatar
  • 2,595
-1 votes
1 answer
63 views

Optimal Selection in Ruby

Given an array of values, arr = [8,10,4,5,3,7,6,0,1,9,13,2] X is an array of values can be chosen at a time where X.length != 0 and X.length < arr.length The chosen values are then fed into a ...
d123's user avatar
  • 1,567
0 votes
3 answers
135 views

Ruby Array: string into integer

I'm new to Ruby. I have a series of arrays with two strings each: ["[[\"Wayfair \", \"57\"]]", "[[\"Move24 \", \"26\"]]", "[[\"GetYourGuide \", \"25\"]]", "[[\"Visual Meta \", \"22\"]]", "[[\"...
catch22's user avatar
  • 1,593
-1 votes
2 answers
391 views

How to key-value store with history (through timestamps) in ruby?

I want to store a bunch of elements inside a hash, but the key must be the timestamp at that time. How should I go about doing something like this? This is in pure Ruby not Rails.
manyo's user avatar
  • 1
1 vote
1 answer
381 views

Bind ERB Template from more than one class

I am trying to interpolate ERB template from multiple objects in Ruby. It works fine if the source of variables is one class. Whats the best way of doing the interpolation when the ERB contains ...
jaypal singh's user avatar
  • 75.9k
0 votes
1 answer
287 views

Error in using dashing on raspbian

I've trying to implement dashing on a raspberry(1) witj raspbian (jessie lite). Once i've installed raspbian, i've done the following things with success : sudo apt-get update sudo apt-get install ...
Nightf's user avatar
  • 61
-1 votes
2 answers
795 views

regex to check url format [closed]

I want to check if my url format is correct, it has some AWS acces keys etc: /https://bucket.s3.amazonaws.com/path/file.txt?AWSAccessKeyId=[.+]&Expires=[.+]&Signature=[.+]/.match(url) ^ ...
J. Doe's user avatar
  • 65
6 votes
2 answers
10k views

Rails 5 - nested controllers with routes

I'm trying to make an app in Rails 5. In order to keep the file structure neat, I'm trying to make folders inside my controllers directory, that I can use to group similar resources. For example, I ...
Mel's user avatar
  • 2,595
0 votes
1 answer
780 views

LoadError: cannot load such file -- dbd-mysql

i could use a little assistance... I have searched everywhere and can't seem to find anything pertaining to this particular gem throwing errors. I just installed dbi mysql and dbd-mysql gems just ...
Micky Scandal's user avatar
1 vote
0 answers
557 views

How to refer rails session from grape api

I try to refer rails session from grape api. I used grape_session library(https://github.com/faber-lotto/grape_session). And I refer same name Rails session parameter from grape api. But session of ...
yone's user avatar
  • 121
2 votes
1 answer
355 views

In Ruby (or Rails), is it faster to compare two large Strings as is, or convert it into Fixnum before using uniq? [closed]

Given 2000 Story objects, each with a body attribute that equates to a string of about 500 characters. What is the fastest way to compare them? Doing it like this: @stories.uniq { |story| story....
Ka Mok's user avatar
  • 1,978
2 votes
1 answer
202 views

Change font size of notebook tabs in ruby tk

Using ruby (1.9.1) with tk, I am creating a simple notebook/tab page. I want to change the font of the tabs and haven't found a way to do that yet, though I know it can be done in other languages. ...
David Ljung Madison Stellar's user avatar
5 votes
3 answers
14k views

Rails: An unhandled lowlevel error occurred. The application logs may have details

I made this on my server: deploy@ubuntu-512mb-ams2-01:~/applications/spa_backend/current$ bundle exec rake secret 4b921910** deploy@ubuntu-512mb-ams2-01:~/applications/spa_backend/current$ export ...
Pavel's user avatar
  • 2,133
1 vote
1 answer
84 views

Ruby-on-Rails toggleable sidebar to edit particular item of list

I have a table displaying a collection of cards, one card per row. When I click on a particular row, I get redirected to the page where I can edit this card. I would like to edit them in a toggleable ...
V. Déhaye's user avatar
0 votes
2 answers
82 views

In RoR, how do I initialize fields in my model based on a field in my model that has no underlying database column?

I’m using Rails 4.2.7. I have an attribute in my model that doesn’t have a database field underneath it attr_accessor :division This gets initialized when I create a new object. my_object = ...
user avatar
0 votes
2 answers
128 views

Bundler claims that it is installing pg but later complains that it can't install it (RHEL7)

Do you know why bundler would claim that it’s installing the pg gem and then afterward complain that it can’t compile it? It indicates that gems are not installed in parallel, but then goes on to ...
Angelo's user avatar
  • 338
5 votes
4 answers
3k views

Rails 5 very slow startup on Windows

I have installed RoR 5 in my laptop Windows 10 SSD 4gb ram i5 5thgen I started working on a project which i wanted to specificaly test under windows , and i noticed some lags and latency. So i ...
frcake's user avatar
  • 254
0 votes
0 answers
45 views

TWO dynamic dropdowns with ONE model

I have a search field where I want to add two dropdowns that should help me filter my search results. In my database I have one Product model with two columns, named country and type. The first ...
AaronDT's user avatar
  • 4,020
2 votes
1 answer
515 views

Issue finding controller concerns only in production

My application has a number of controller concerns in app/controllers/api/V2/concerns When I work on this in development, everything works well. However, as soon as I push to production, I get the ...
Karim's user avatar
  • 1,303
5 votes
3 answers
247 views

How can I show that the Ruby `for` loop is in fact implemented using the `each` method?

In the book Eloquent Ruby (page 21, first edition, sixth printing), the author (Russ Olsen) advocates using the each method instead of the for loop and this is in line with everything I've read ...
Sagar Pandya's user avatar
  • 9,424
-2 votes
3 answers
84 views

Where should I call a Ruby class method?

I have a Ruby method: class ClassOfSomeSort def self.methodOfSomeSort(argument) ... end methodOfSomeSort(5) end I heard calling the method in the class itself is a bad practise. Where ...
Jes's user avatar
  • 323
0 votes
0 answers
34 views

URL's in body of text being changed into relative url rather than using given url

I recently migrated old data from a news site into a new platform built using Ruby on Rails. Mostly seamless migration except for one thing that I have not been able to figure out. Inside the body ...
Aaron Wortham's user avatar
0 votes
1 answer
762 views

Rails custom error pages won't render on Nginx

I am new to Rails and Nginx. I was asked to add custom error pages to our app. I found instructions to do so on this site and my custom error pages render just fine locally. When I go to the url /...
zilla's user avatar
  • 18
0 votes
1 answer
1k views

Change owner of everything inside a directory

I am using teh following directory chef resource to change ownership of all files within /etc/temp.d directory. [ /etc/temp.d ].each do |path| directory path do recursive true owner ...
meallhour's user avatar
  • 14.9k
0 votes
1 answer
187 views

Unable to use [square bracket] method in Custom Ruby class?

I am learning Composite method from Design Patterns in Ruby. I came across the following code. The goal is to have a base Task; in this case its job is to keep track of time and that's it. There are ...
Iggy's user avatar
  • 5,179
1 vote
1 answer
585 views

How to make a general method to check for winners in Tic-Tac-Toe

I made a Tic-Tac-Toe game in Ruby. The method below checks for a winner in the vertical columns. How do I make it so that this method can be applied to boards of different sizes, like 4x4, 6x6? def ...
Paly CS's user avatar
  • 19
3 votes
1 answer
3k views

Ruby on Rails: Get nested modules?

In my Rails project I want to get all modules that are nested inside the module A. The file lib/assets/a/b.rb, consists of: module A module B end end In the Rails console: A.constants => [...
Vorpulus Lyphane's user avatar
0 votes
2 answers
58 views

Rails having a naming error on a form_for that is causing an unknown path error

The issue is I get this nasty little controller error... NoMethodError in Contacts#new undefined method `contacts_path' for #<#:0x0000000124b228> Did you mean? contact_path on my view: contact#...
ekr990011's user avatar
0 votes
1 answer
4k views

How to fix cannot load such file -- Nokogiri (LoadError) in c9.io?

I'm using Cloud9 IO for Ruby. I ran bundle install. Even installed the gems. But I'm still getting this error. scarletmclearn:~/workspace/nokogiri_tutorial (master) $ ruby web_scraper.rb /usr/...
Scarlet McLearn's user avatar
0 votes
1 answer
2k views

Filter chain halted as :redirect_admin rendered or redirected

When I try to login to my Rails application, I'm getting the following error in the logs: I, [2016-10-03T11:44:17.136518 #13441] INFO -- : Started GET "/" for 72.238.233.104 at 2016-10-03 11:44:17 -...
Godzilla74's user avatar
  • 2,442
0 votes
1 answer
940 views

RSpec: testing sidekiq worker for race condition

Sometimes I have situation when the same worker running twice - when user sending requests fast, one by one. I added condition: if worker was already started and inside worker's payload is class ...
kwaigon's user avatar
  • 785
53 votes
20 answers
97k views

Homebrew install: Failed during: git fetch origin master:refs/remotes/origin/master -n --depth=1

I ran the following command on terminal (Mac El Capitan) $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" and got the following error message: ...
anm's user avatar
  • 1,877
4 votes
1 answer
668 views

How to align horizontally a multiline CLI help text with OptionParser

I am trying to make the output of my CLI Ruby gem my_command --help cleaner. There is some CLI options and flags that need a couple of sentences to explain them. I don't have found a way to properly ...
Hartator's user avatar
  • 5,127
1 vote
1 answer
50 views

How to display a certain value from nested hash

I am trying create an app where the user could transform his name or a word with chemical elements (like breaking bad logo). After couple of questions here, trying, and long reflexion I that I have ...
user avatar
0 votes
1 answer
32 views

Rails 4: Order Loops depending on HTML Selector

I wanted to do that for a while now, and I am just missing the right approach I guess. What I exactly want to do. I have a loop through items and just want to order them differently depending on what ...
Gugubaight's user avatar
0 votes
1 answer
835 views

What's the best way to store checkboxes in a PostGres database

what would be the best way to store a student's vehicle in a database? They can select bike, scooter or car. Some say the best way is to store a hash in the database (what would the attribute type be?...
crievino's user avatar