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
59
votes
3 answers

Dotenv multiline variables

I'm using dotenv. A Ruby gem to load environment variables from .env. Is it possible to have multiline variables in my .env file? e.g. SOMETHING_CERTIFICATE="-----BEGIN…
Mirror318
  • 11,875
  • 14
  • 64
  • 106
59
votes
4 answers

accepts_nested_attributes_for with belongs_to polymorphic

I would like set up a polymorphic relation with accepts_nested_attributes_for. Here is the code: class Contact :client end class Job :true …
dombesz
  • 7,890
  • 5
  • 38
  • 47
59
votes
5 answers

How to count lines of code?

I tried rake stats but that seems highly inaccurate. Perhaps it ignores several directories?
AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012
59
votes
4 answers

Ruby on Rails: alias_method_chain, what exactly does it do?

I've tried reading through various blog posts that attempt to explain alias_method_chain and the reasons to use it and not use it. In particular, I took heed…
randombits
  • 47,058
  • 76
  • 251
  • 433
59
votes
3 answers

Ruby global match regexp?

In other languages, in RegExp you can use /.../g for a global match. However, in Ruby: "hello hello".match /(hello)/ Only captures one hello. How do I capture all hellos?
never_had_a_name
  • 90,630
  • 105
  • 267
  • 383
59
votes
3 answers

Ruby on Rails: How do you explicitly define plural names and singular names in Rails?

For example, I'm using "Bonus" as my model, so I'd expect "bonuses" to be the plural form and "bonus" to be the singular form. However, in Ruby, this results in: "bonus".pluralize # bonus "bonuses".singularize # bonuse So, when I do a "has_many…
sjsc
  • 4,552
  • 10
  • 39
  • 55
59
votes
6 answers

How do I update Ruby-interpreters with RVM?

I installed RVM with a few versions of Ruby-interpreters some time ago. How I can to update it, because new versions are already released? I found only one way: rvm install 1.9.2-rc1 && rvm remove 1.9.2-preview1, but my gems are lost. Can I update…
mystdeim
  • 4,802
  • 11
  • 49
  • 77
59
votes
7 answers

Capistrano asks for password when deploying, despite SSH keys

My ssh keys are definitely set up correctly, as I'm never prompted for the password when using ssh. But capistrano still asks for a password when deploying with cap deploy. It doesn't ask for the password when I setup with cap deploy:setup though,…
ehsanul
  • 7,737
  • 7
  • 33
  • 43
59
votes
2 answers

migrations: t.references doesn't allow index name to be specified

I have the following in a migration: create_table :model_with_a_long_name do |t| t.references :other_model_with_an_equally_long_name, index: true end That produces an index with too long of a name for Postgres. Is there a way to manually specify…
Drew Dara-Abrams
  • 8,016
  • 11
  • 40
  • 48
59
votes
2 answers

Where are my ruby gems?

Linux newbie question I guess.. How can I find out where gem installs the gems on my Ubuntu 10 system? I want to read gem sourcecode and perhaps change things up a bit.
scrrr
  • 5,135
  • 7
  • 42
  • 52
59
votes
13 answers

Bundle not working with rbenv

I'm trying to use bundler with rbenv. I has been working until today. The only thing I may have done to break it was gem pristine --all or gem cleanup ? When trying to install bundler i get the following error. Antarrs-MacBook-Pro:some-app…
Antarr Byrd
  • 24,863
  • 33
  • 100
  • 188
59
votes
5 answers

Fill array with element N times

I want to fill an array with 1 element but 5 times. What I got so far. number = 1234 a = [] 5.times { a << number } puts a # => 1234, 1234, 1234, 1234, 1234 It works but this feels not the ruby way. Can someone point me in the right direction to…
AME
  • 2,262
  • 6
  • 19
  • 39
59
votes
8 answers

Check whether a string contains one of multiple substrings

I've got a long string-variable and want to find out whether it contains one of two substrings. e.g. haystack = 'this one is pretty long' needle1 = 'whatever' needle2 = 'pretty' Now I'd need a disjunction like this which doesn't work in Ruby…
Hedge
  • 16,142
  • 42
  • 141
  • 246
59
votes
4 answers

Create .ruby-version and .ruby-gemset with rvm

Is there a way to create the associated .ruby-version and .ruby-gemset files when creating a new gemset? With older versions of rvm, one could do rvm --create --rvmrc 1.8.7@project, but that creates .rvmrc files. I thought I read somewhere we could…
Tyler DeWitt
  • 23,366
  • 38
  • 119
  • 196
59
votes
3 answers

Warning with fog and AWS: unable to load the 'unf' gem

Every action in a rails console (rails server, rails console, db:migrate, etc.) raises a warning since my last bundle update: [fog][WARNING] Unable to load the 'unf' gem. Your AWS strings may not be properly encoded. I'm sure I didn't change…
Arenzel
  • 1,156
  • 1
  • 11
  • 18