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
61
votes
4 answers

What does "wrong number of arguments (1 for 0)" mean in Ruby?

What does "Argument Error: wrong number of arguments (1 for 0)" mean?
Kotaro Ezawa
  • 1,509
  • 3
  • 13
  • 11
61
votes
5 answers

Can't Install ffi -v '1.9.18' on macos Catalina

Can't install specific ffi version. If I run gem install ffi, everything works just fine but I need specific version 1.9.18 and it doesn't work. Fetching ffi 1.9.18 Installing ffi 1.9.18 with native extensions Gem::Ext::BuildError: ERROR: Failed to…
Denis Omerovic
  • 1,420
  • 1
  • 10
  • 23
61
votes
5 answers

Upgrading from Rails 3 to Rails 3.1

How do you upgrade from Rails 3 to Rails 3.1 beta?
user730569
  • 3,940
  • 9
  • 42
  • 68
61
votes
4 answers

What’s the best way to handle exceptions from Net::HTTP?

What’s the best way to rescue exceptions from Net::HTTP? Exceptions thrown are described in Ruby’s socket.c, like Errno::ETIMEDOUT, Errno::ECONNRESET, and Errno::ECONNREFUSED. The base class to all of these is SystemCallError, but it feels weird to…
Edward Ocampo-Gooding
  • 2,782
  • 1
  • 23
  • 29
61
votes
3 answers

Rails 5.2.0 with Ruby 2.5.1 console - `warning:` `already` initialized constant FileUtils::VERSION

I'm currently experiencing an issue with my new rails application, more specifically: Rails 5.2.0 Ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17] rvm 1.29.4 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin…
vchar
  • 956
  • 1
  • 11
  • 15
61
votes
3 answers

What does the underscore mean in literal numbers?

What does that mean? 0.0..10_000.0
auralbee
  • 8,741
  • 4
  • 29
  • 36
61
votes
7 answers

Rails bundler doesn't install gems inside a group

I have several gems including ruby-debug in a bundler group called :development. When I run the bundle command, these gems are ignored and it only installs the gems that are not in any group. How can I make sure bundler doesn't ignore the gems in…
picardo
  • 24,530
  • 33
  • 104
  • 151
61
votes
3 answers

A method with an optional parameter

Is there a way to make a method that can accept a parameter, but can also be called without one, in which case the parameter is regarded nil like the following? some_func(variable) some_func
TamRock
  • 1,490
  • 1
  • 11
  • 27
61
votes
4 answers

How do I run Rake tasks within a Ruby script?

I have a Rakefile with a Rake task that I would normally call from the command line: rake blog:post Title I'd like to write a Ruby script that calls that Rake task multiple times, but the only solution I see is shelling out using `` (backticks) or…
Mando Escamilla
  • 1,560
  • 1
  • 10
  • 17
61
votes
11 answers

Error message: Make sure that `gem install pg -v '0.18.1'` succeeds before bundling

i have a problem with ruby. I tried a lot but nothing works for me. When i want to start the rails server, i get this error message: An error occurred while installing pg (0.18.1), and Bundler cannot continue. Make sure that "gem install pg -v…
phd
  • 819
  • 1
  • 7
  • 11
61
votes
3 answers

Add nullable foreign key in Rails

Referencing to Rails 4.2 add_foreign_key support: # add a foreign key to `articles.author_id` referencing `authors.id` add_foreign_key :articles, :authors How to create a nullable foreign key constraint, to allow the situation, where…
61
votes
10 answers

Array.include? multiple values

[2, 6, 13, 99, 27].include?(2) works well for checking if the array includes one value. But what if I want to check if an array includes any one from a list of multiple values? Is there a shorter way than doing Array.include?(a) or Array.include?(b)…
Aaron Hooper
  • 798
  • 2
  • 6
  • 14
61
votes
2 answers

Passing headers and query params in HTTparty

How to pass query params and headers in post method using HTTparty. I am doing as follows But it throws query = {:method => "neworder", :nonce => 1404996028, :order_type => "buy", :quantity=>1,:rate=>1} headers = {:key=> "87819747209090199871234",…
Sam
  • 5,040
  • 12
  • 43
  • 95
61
votes
2 answers

Guard with RSpec on Rails 4 giving a lot of warnings

I'm wondering how I can turn off all these warnings when running a simple test: [1] guard(main)> 16:59:46 - INFO - Run all 16:59:46 - INFO - Running all specs /Users/esjd/.rvm/gems/ruby-2.1.2/gems/rspec-rails-3.0.1/lib/rspec/rails/adapters.rb:124:…
foobar
  • 10,854
  • 18
  • 58
  • 66
61
votes
15 answers

Which key/value store is the most promising/stable?

I'm looking to start using a key/value store for some side projects (mostly as a learning experience), but so many have popped up in the recent past that I've got no idea where to begin. Just listing from memory, I can think…
Mike Trpcic
  • 25,305
  • 8
  • 78
  • 114