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].

The tag is for questions related to the Ruby language, including its syntax and its libraries. Questions specifically about the Ruby on Rails framework should be tagged with in addition to . Do not use this to tag ruby used in the Japanese language.

Ruby is an open-source dynamic object-oriented interpreted language that combines concepts from Perl, Smalltalk, and Lisp. It supports multiple programming paradigms including functional, object-oriented, and imperative. It also has a dynamic type system and automatic memory management; it is, therefore, similar in varying respects to Smalltalk, Python, Perl, Lisp, Dylan, and CLU. Ruby's primary purpose is to "help every programmer in the world to be productive, and to enjoy programming, and to be happy." Ruby focuses on simplicity and productivity.

Ruby was initially conceived on February 24, 1993, by Yukihiro Matsumoto ('Matz') and version 1.0 was released in 1996. Ruby's mindshare spiked around 2005 due to Ruby on Rails, an MVC (Model, View, Controller) framework for building web applications and usage continues to grow as of 2016 with Ruby continuing to find acceptance in the commercial marketplace. The current stable version is 3.2.0 (2022-12-25).

Documentation, Announcements, Issue Tracker

Unofficial Reference

Implementations, Installers

  • Ruby version managers. chruby, rbenv, rvm, pik (Windows)
  • Ruby, the official implementation also known as Matz' Ruby Implementation (MRI), YARV-Ruby. Official Site, GitHub
  • JRuby, an implementation of Ruby on top of Java with access to the JVM
  • Rubinius, an implementation of Ruby supporting native OS threads and a core library written almost entirely in Ruby
  • Ruby Enterprise Edition (not maintained anymore), a branch of MRI Ruby made for efficiency
  • MacRuby, an implementation of Ruby on Apples Objective-C and Cocoa frameworks
  • MagLev an implementation on top of VMWare's GemStone virtual machine
  • IronRuby is an implementation of Ruby on top of Microsoft's .NET CLR/DLR platform
  • Cardinal is an implementation of Ruby for the Parrot Virtual Machine
  • Topaz is an implementation of Ruby written in Python, on top of RPython
  • RubyMotion is an implementation of Ruby to develop native iOS and OS X applications

Gems (Library)

  • Ruby Gems - The Standard Library
  • Ruby Toolbox - Ruby Gems categorization, ranking, and statistics
  • Awesome Ruby - A categorized collection of awesome Ruby libraries, tools, frameworks, and software. The essential Ruby to build modern Apps and Web Apps
  • Bundler - Manage your application's gem dependencies
  • DevKit - A windows toolkit that makes it easy to build and use native C/C++ extensions

Tools

  • repl.it - Online REPL
  • RSpec - A testing tool for Ruby
  • Minitest - A testing tool for Ruby
  • Rubular - A Ruby regular expression tool
  • Pry - REPL and debugger for Ruby
  • Rubocop - A Ruby linter and code formatter

Online Courses

Books

Related Tags


Icon:

ruby icon

228397 questions
62
votes
7 answers

Is there a pluralize function in Ruby NOT Rails?

I am writing some Ruby code, not Rails, and I need to handle something like this: found 1 match found 2 matches I have Rails installed so maybe I might be able to add a require clause at the top of the script, but does anyone know of a RUBY method…
aarona
  • 35,986
  • 41
  • 138
  • 186
62
votes
5 answers

Why is it best to store a telephone number as a string vs. integer?

As the question states, why is it considered best practice to store telephone numbers as strings rather than integers in the telephone_number column? Not sure I understand the rationale for this. Please help clear this up! Thanks!
user3399101
  • 1,477
  • 3
  • 14
  • 29
62
votes
5 answers

TypeError: no implicit conversion of Symbol into Integer

I encounter a strange problem when trying to alter values from a Hash. I have the following setup: myHash = { company_name:"MyCompany", street:"Mainstreet", postcode:"1234", city:"MyCity", free_seats:"3" } def cleanup string …
Severin
  • 8,508
  • 14
  • 68
  • 117
62
votes
4 answers

Including rake tasks in gems

1) Is there a 'best' place for rake tasks inside of gems? I've seen them in /tasks, /lib/tasks, and I've seen them written as *.rb and *.rake -- not sure which (if any) is 'correct' 2) How do I make them available to the app once the gem is…
jsharpe
  • 2,546
  • 3
  • 26
  • 42
62
votes
6 answers

Rails 4 Unpermitted Parameters for Array

I have an array field in my model and I'm attempting to update it. My strong parameter method is below def post_params params["post"]["categories"] = params["post"]["categories"].split(",") params.require(:post).permit(:name, :email,…
thank_you
  • 11,001
  • 19
  • 101
  • 185
62
votes
7 answers

How do I reset my sidekiq counters?

In my sidekiq dashboard, I see on the left a box with the counters Processed 168 Failed 111 Busy 0 Scheduled 0 Retries 0 Enqueued 0 How do I reset them all to 0?
AgostinoX
  • 7,477
  • 20
  • 77
  • 137
62
votes
6 answers

How to fix bad URI is not URI

I'm using the ruby version 1.9.3, I like to get host name from the video url below, I tried with code require 'uri' url =…
prabu
  • 6,121
  • 8
  • 35
  • 39
62
votes
3 answers

How to enable auto completion in Ruby's IRB

When I use Merb's built in console, I get tab auto-completion similar to a standard bash prompt. I find this useful and would like to enable it in non-merb IRB sessions. How do I get auto-completion in IRB?
John F. Miller
  • 26,961
  • 10
  • 71
  • 121
62
votes
9 answers

Can FactoryBot generate factories after your models have been created?

When including the factory_bot_rails gem in your dev and test blocks in Gemfile, rails will generate factories automatically when your models are generated. Is there a way to generate factories after your models have been generated? Note:…
GuiDoody
  • 897
  • 1
  • 6
  • 13
62
votes
2 answers

Is it possible to read a file's modification date with Ruby?

Is it possible to read a file's modification date with Ruby? I have successfully opened a text file and captured the contents of the file with File.open("test.txt", "r").each do |line|" but it would be very useful to read the modification date of…
ryan1393402
  • 715
  • 1
  • 6
  • 9
61
votes
1 answer

How to get PID of current rake task?

I'm putting in a reaper line into a rake task to kill some additionally spawned ruby tasks as they somehow creep up on occasion. system "ps aux | grep 'namespace:taskname' | grep ruby | grep -v grep | awk '{print $2}' | xargs kill -9; echo 'Reaped…
ylluminate
  • 12,102
  • 17
  • 78
  • 152
61
votes
9 answers

Rails 3. How to get the difference between two arrays?

Let’s say I have this array with shipments ids. s = Shipment.find(:all, :select => "id") [#, #, #, #, #] Array of invoices with shipment id's i = Invoice.find(:all,…
leonel
  • 10,106
  • 21
  • 85
  • 129
61
votes
15 answers

How do I convert a Ruby hash so that all of its keys are symbols?

I have a Ruby hash which looks like: { "id" => "123", "name" => "test" } I would like to convert it to: { :id => "123", :name => "test" }
ed1t
  • 8,719
  • 17
  • 67
  • 110
61
votes
10 answers

Vim Command-T plugin error: could not load the C extension

I'm trying to install the Command-T plugin. I compiled vim following the instructions in this comment: Installing vim with ruby support (+ruby) So now there's the +ruby flag, but still when I try to use the plugin I get this error: command-t.vim…
Carlo
  • 4,016
  • 7
  • 44
  • 65
61
votes
10 answers

How can I do standard deviation in Ruby?

I have several records with a given attribute, and I want to find the standard deviation. How do I do that?
Satchel
  • 16,414
  • 23
  • 106
  • 192