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
9 answers

How to convert array of ActiveRecord models to CSV?

I got an array of ActiveRecord models that I wish to convert to a CSV. I tried researching gems like FasterCSV, but they just seem to work with strings and arrays, not ActiveRecord models. In short, I want to convert: user1 = User.first user2 =…
Henley
  • 21,258
  • 32
  • 119
  • 207
59
votes
11 answers

Converting upper-case string into title-case using Ruby

I'm trying to convert an all-uppercase string in Ruby into a lower case one, but with each word's first character being upper case. Example: convert "MY STRING HERE" to "My String Here". I know I can use the .downcase method, but that would make…
wsb3383
  • 3,841
  • 12
  • 44
  • 59
59
votes
8 answers

"bin/rails: No such file or directory" w/ Ruby 2 & Rails 4 on Heroku

While following the Rails 4 Beta version of Michael Hartl's Ruby on Rails Tutorial, my app fails to start on Heroku, but runs fine locally with bundle exec rails server. Checking heroku logs -t reveals the following error: $ heroku[web.1]: State…
Justin Garrick
  • 14,767
  • 7
  • 41
  • 66
59
votes
9 answers

How to handle Ruby on Rails error: "Please install the postgresql adapter: `gem install activerecord-postgresql-adapter'"

Running a Ruby on Rails (RoR) app or Ruby code which uses the ActiveRecord framework, you get the error message: Please install the postgresql adapter: gem install activerecord-postgresql-adapter Trying to run: gem install…
user71268
  • 769
  • 1
  • 5
  • 6
59
votes
3 answers

How to use ActiveRecord in a ruby script outside Rails?

I have a small ruby script in which I'd like to use ActiveRecord to easily access a database model. What is the best way to do it?
Daniel Cukier
  • 11,502
  • 15
  • 68
  • 123
59
votes
3 answers

Why does explicit return make a difference in a Proc?

def foo f = Proc.new { return "return from foo from inside proc" } f.call # control leaves foo here return "return from foo" end def bar b = Proc.new { "return from bar from inside proc" } b.call # control leaves bar here return…
uzo
  • 2,821
  • 2
  • 25
  • 26
59
votes
7 answers

Get last day of the month in Ruby

I made new object Date.new with args (year, month). After create ruby added 01 number of day to this object by default. Is there any way to add not first day, but last day of month that i passed as arg(e.g. 28 if it will be 02month or 31 if it will…
sanny Sin
  • 1,555
  • 3
  • 17
  • 27
59
votes
8 answers

How to break outer cycle in Ruby?

In Perl, there is an ability to break an outer cycle like this: AAA: for my $stuff (@otherstuff) { for my $foo (@bar) { last AAA if (somethingbad()); } } (syntax may be wrong), which uses a loop label to break…
Fluffy
  • 27,504
  • 41
  • 151
  • 234
59
votes
3 answers

Override ruby constant in subclass so inherited methods use new constant instead of the old?

In Ruby, is there a way to 'override' a constant in a subclass in such a way that calling an inherited method from the subclass results in that method using the new constant instead of the old one? For example: class SuperClass CONST = "Hello,…
Ajedi32
  • 45,670
  • 22
  • 127
  • 172
59
votes
8 answers

Get class location from class object

I have a bunch of code to look at, and now it is debugging time. Since I have never been a fan of Ruby's debugger I am looking for a way of going through code and reading it. What I am trying to do is get the location of the file where a loaded…
Haris Krajina
  • 14,824
  • 12
  • 64
  • 81
59
votes
7 answers

Raise custom Exception with arguments

I'm defining a custom Exception on a model in rails as kind of a wrapper Exception: (begin[code]rescue[raise custom exception]end) When I raise the Exception, I'd like to pass it some info about a) the instance of the model whose internal functions…
Chris Keele
  • 3,364
  • 3
  • 30
  • 52
59
votes
2 answers

"Uninitialized constant" error when including a module

I am trying to reference an association extension but it errors with: NameError (uninitialized constant User::ListerExtension): app/models/user.rb:2:in `' Here is my implementation: app/models/user.rb class User < ActiveRecord::Base …
Coderama
  • 11,050
  • 12
  • 44
  • 58
59
votes
2 answers

Parsing XML with Ruby

I'm way new to working with XML but just had a need dropped in my lap. I have been given an usual (to me) XML format. There are colons within the tags. 1234
n8gard
  • 1,870
  • 8
  • 26
  • 41
59
votes
7 answers

Nicely formatting output to console, specifying number of tabs

I am generating a script that is outputting information to the console. The information is some kind of statistic with a value. So much like a hash. So one value's name may be 8 characters long and another is 3. when I am looping through outputting…
user130532
59
votes
2 answers

Sublime Text 2 console input

I use Sublime Text 2 but it won't let me enter any value when my code asks for user input. (In other words: input() in Python and gets in Ruby fail to correctly prompt me for input). Python throws an EOFError error (what you get when user doesn't…
roflol
  • 637
  • 2
  • 7
  • 9