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

How to merge Ruby hashes

How can I merge these two hashes: {:car => {:color => "red"}} {:car => {:speed => "100mph"}} To get: {:car => {:color => "red", :speed => "100mph"}}
skyporter
  • 847
  • 1
  • 7
  • 14
65
votes
10 answers

ActiveRecord Arel OR condition

How can you combine 2 different conditions using logical OR instead of AND? NOTE: 2 conditions are generated as rails scopes and can't be easily changed into something like where("x or y") directly. Simple example: admins = User.where(:kind =>…
Dmytrii Nagirniak
  • 23,696
  • 13
  • 75
  • 130
65
votes
3 answers

Factory Girl - what's the purpose?

What's the purpose of Factory Girl in rspec tests when I could use before(:each) blocks? It feels like the only difference between Factory Girl and a before(:each) is that the factory prepares object creation outside of the test. Is this right?
curiousdork
  • 1,034
  • 2
  • 12
  • 13
65
votes
8 answers

Combine two Arrays into Hash

I've got two Arrays: members = ["Matt Anderson", "Justin Biltonen", "Jordan Luff", "Jeremy London"] instruments = ["guitar, vocals", "guitar", "bass", "drums"] What I would like to do is combine these so that the resulting data structure is a…
Michael Irwin
  • 3,119
  • 5
  • 24
  • 40
65
votes
3 answers

Why does expression (true == true == true) produce a syntax error?

Ruby: true == true == true syntax error, unexpected tEQ vs. JavaScript: true == true == true // => true vs. C: 1 == 1 == 1 // => 1
65
votes
6 answers

How to test for (ActiveRecord) object equality

In Ruby 1.9.2 on Rails 3.0.3, I'm attempting to test for object equality between two Friend (class inherits from ActiveRecord::Base) objects. The objects are equal, but the test fails: Failure/Error: Friend.new(name: 'Bob').should…
ryonlife
  • 6,563
  • 14
  • 51
  • 64
65
votes
6 answers

Rails Unable to convert unpermitted parameters to hash

I am trying to implement a simple search and sort for my webapp. I am following the railscast and this railscast. My application helper for sortable function which I am using as link is: def sortable(column, title = nil) title ||=…
Saurav Prakash
  • 1,177
  • 1
  • 11
  • 25
65
votes
15 answers

Why can't I install the SQLite gem?

I'm try to install the SQLite gem on a Fedora 9 Linux box with Ruby 1.8.6, Rails 2.2.2, gem 1.3, and sqlite-3.5.9. Here's the command I'm running and its results: sudo gem install sqlite3-ruby Building native extensions. This could take a…
Eric Noob
  • 1,471
  • 3
  • 15
  • 14
65
votes
26 answers

database configuration does not specify adapter

I'm getting this error when I'm trying to connect to a mysql database. The problem is that the application works for weeks, and then randomly I get this message. When I get this error message the application is not able to reconnect to the database…
Roberto
  • 1,450
  • 1
  • 15
  • 32
65
votes
6 answers

Cannot install thin on windows

I cannot install thin gem on windows. Something happen during build of native extensions. Do anybody face same issues? Here is the stack trace: >gem install thin --no-ri --no-rdoc Temporarily enhancing PATH to include DevKit... Building native…
Alexey Zakharov
  • 24,694
  • 42
  • 126
  • 197
65
votes
7 answers

What is the meaning of "h" in "<%=h [ ...] %>"?

When I generate a default scaffold, the display tags on show.html.erb have <%=h @broker.name %> I know the difference between <% and <%=. What's the "h" do?
neezer
  • 19,720
  • 33
  • 121
  • 220
65
votes
7 answers

In Ruby, what is the cleanest way of obtaining the index of the largest value in an array?

If a is the array, I want a.index(a.max), but something more Ruby-like. It should be obvious, but I'm having trouble finding the answer at so and elsewhere. Obviously, I am new to Ruby.
Cary Swoveland
  • 106,649
  • 6
  • 63
  • 100
65
votes
2 answers

How do I remove a node with Nokogiri?

How can I remove tags using Nokogiri? I have the following code but it wont work: # str = 'testtfbu' f =…
all jazz
  • 2,007
  • 2
  • 21
  • 37
65
votes
4 answers

Difference between the access modes of the `File` object (ie. w+, r+)

When using files in Ruby, what is the difference between the r+ and w+ modes? What about the a+ mode?
Just a learner
  • 26,690
  • 50
  • 155
  • 234
65
votes
3 answers

How to make the class constructor private in Ruby?

class A private def initialize puts "wtf?" end end A.new #still works and calls initialize and class A private def self.new super.new end end doesn't work altogether So what's the correct way? I want to make new private and call…
Leonid Shevtsov
  • 14,024
  • 9
  • 51
  • 82