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
64
votes
6 answers

Ruby way to check if a string is not blank?

What's the best way to check if a variable is not blank in an else if condition in Ruby (not Rails)? elsif not variable.to_s.empty? # do something end or elsif !variable.to_s.empty? # do something end or elsif variable.to_s.length > 0 # do…
Rajkaran Mishra
  • 4,532
  • 2
  • 36
  • 61
64
votes
6 answers

Bundle command not found mac

I'm using ruby, and I was given a zip file with some ruby programs and it says: inside the folder, run bundle install to install the packages required. When I run the command in my terminal, it says bundle command not found. Can someone please…
ytk
  • 2,787
  • 4
  • 27
  • 42
64
votes
2 answers

Resize existing images to new style in paperclip & RMagick

I've been using paperclip to upload and auto-resize photos in my Rails app, and I love it. Only problem is about every other month my crazy manager decides he wants a new size to display the photos in. So I add a new style in my Photo model and all…
tybro0103
  • 48,327
  • 33
  • 144
  • 170
64
votes
10 answers

rbenv install --list does not list version 2.1.2

I installed rbenv via Homebrew on an OS X 10.9.3 MacBook Pro: brew update brew upgrade rbenv ruby-build According to rbenv install --list on my laptop Ruby 2.1.0-dev is the latest.
levy
  • 833
  • 1
  • 6
  • 9
64
votes
7 answers

Mysql2::Error: Incorrect string value

I have a rails application running on production mode, but all of the sudden this error came up today when a user tried to save a record. Mysql2::Error: Incorrect string value More details (from production log): Parameters: {"utf8"=>"â<9c><93>" ...…
Trt Trt
  • 5,330
  • 13
  • 53
  • 86
64
votes
3 answers

How to convert a string to UTF8 in Ruby

I'm writing a crawler which uses Hpricot. It downloads a list of strings from some webpage, then I try to write it to the file. Something is wrong with the encoding: "\xC3" from ASCII-8BIT to UTF-8 I have items which are rendered on a webpage and…
ciembor
  • 7,189
  • 13
  • 59
  • 100
64
votes
14 answers

ruby 2.0 rails gem install error "cannot load such file -- openssl"

I am using osx 10.8.2 installed ruby 2.0 and.... got this when trying to run "sudo gem install rails" $ sudo gem install rails ERROR: Loading command: install (LoadError) cannot load such file -- openssl ERROR: While executing gem ...…
Stephen Nguyen
  • 5,357
  • 5
  • 24
  • 28
64
votes
5 answers

How to signal "not implemented yet"?

In the initial drafting of a new gem I need to leave some method implementations empty ( to be implemented in the next ) Therefore, I would like to signal a "not implemented yet" exception I'm wondering if there is a best practice or standard…
Franco Rondini
  • 10,841
  • 8
  • 51
  • 77
64
votes
11 answers

I have a gem installed but require 'gemname' does not work. Why?

The question I'm really asking is why require does not take the name of the gem. Also, In the case that it doesn't, what's the easiest way to find the secret incantation to require the damn thing!? As an example if I have memcache-client installed…
mloughran
  • 11,415
  • 7
  • 28
  • 22
64
votes
7 answers

Using send_file to download a file from Amazon S3?

I have a download link in my app from which users should be able to download files which are stored on s3. These files will be publicly accessible on urls which look something like https://s3.amazonaws.com/:bucket_name/:path/:to/:file.png The…
David Tuite
  • 22,258
  • 25
  • 106
  • 176
64
votes
25 answers

Error Installing Jekyll - Native Extension Build

I'm having some trouble installing jekyll. Can't quite figure out how to patch the missing link. I think it's an update to Ruby, but RVM is having trouble installing alternate versions of ruby as well. Heres the full post: $ sudo gem install jekyll…
Robb Schiller
  • 1,109
  • 2
  • 9
  • 17
64
votes
6 answers

Ruby rails - select only few columns from the database

What is the way in Rails to structure SQL query to only select certain columns from the database, I have some large data fields which I want to avoid loading from continuous periodic Ajax calls. Reading unnecessarily is resource consuming and…
Majoris
  • 2,963
  • 6
  • 47
  • 81
63
votes
4 answers

Xcode - configure: error: no acceptable C compiler found in $PATH

rebuilding a mac from scratch. Installed xcode and rvm then trying to install rubies but they are all giving me: Error running ' ./configure --prefix=/Users/durrantm/.rvm/rubies/ruby-1.9.3-p125 --enable-shared --disable-install-doc --with-libyaml…
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
63
votes
5 answers

What's this &block in Ruby? And how does it get passed in a method here?

Saw this piece of code in a Ruby on Rails book. This first one is from a view and the second one is a helper module. I don't understand how that &block and the attributes={} thing work. Can anyone guide me to a tutorial of some kind explaining…
Malik Daud Ahmad Khokhar
  • 13,470
  • 24
  • 79
  • 81
63
votes
4 answers

What is the answer to the bonus question in test_changing_hashes of Ruby Koans?

In the Ruby Koans, the section about_hashes.rb includes the following code and comment: def test_changing_hashes hash = { :one => "uno", :two => "dos" } hash[:one] = "eins" expected = { :one => "eins", :two => "dos" } assert_equal…
Bruce
  • 8,202
  • 6
  • 37
  • 49