Ruby is an open-source dynamic object-oriented interpreted language created by Yukihiro Matsumoto (Matz) in 1993.

learn more… | top users | synonyms | ruby jobs

123
votes
5answers
30k views

What does map(&:name) mean in Ruby?

I found this code in a RailsCast: def tag_names @tag_names || tags.map(&:name).join(' ') end what does the (&:name) in map(&:name) mean?
39
votes
6answers
3k views

What does ||= (or equals) mean in Ruby?

What does the following code mean in Ruby? ||= Does it have any meaning or reason for the syntax?
99
votes
4answers
16k views

Ruby ampersand colon shortcut [duplicate]

Possible Duplicate: What does map(&:name) mean in Ruby? In Ruby, I know that if I do: some_objects.each(&:foo) It's the same as some_objects.each { |obj| obj.foo } That is, ...
87
votes
1answer
37k views

Installed Ruby 1.9.3 with RVM but command line doesn't show ruby -v

Here's the console output: sergio@sergio-VirtualBox:~$ rvm list rvm rubies ruby-1.9.3 [ i386 ] sergio@sergio-VirtualBox:~$ rvm use 1.9.3 Using /usr/share/ruby-rvm/gems/ruby-1.9.3 ...
222
votes
15answers
59k views

Can't install Ruby under Lion with RVM – GCC issues

Most questions regarding this problem are due to missing Xcode; I have Xcode 4.2 installed. Install attempt: rvm install 1.9.3 Installing Ruby from source to: /Users/jamie/.rvm/rubies/ruby-1.9.3-p0, ...
142
votes
6answers
30k views

Does ruby have real multithreading?

I know about the "cooperative" threading of ruby using green threads. How can I create real "OS-level" threads in my application in order to make use of multiple cpu cores for processing?
118
votes
9answers
7k views

Array slicing in Ruby: looking for explanation for illogical behaviour (taken from Rubykoans.com)

I was going through the exercises at http://rubykoans.com/ and I was struck by the following Ruby quirk that I found really unexplainable: array = [:peanut, :butter, :and, :jelly] array[0] => ...
195
votes
21answers
33k views

Using Rails 3.1, where do you put your “page specific” javascript code?

To my understanding, all of your javascript gets merged into 1 file. Rails does this by default when it adds //= require_tree . to the bottom of your application.js manifest file. This sounds like a ...
34
votes
8answers
12k views

How do I debug ruby scripts?

Ruby n00b here. I copied the following ruby code from the internets and made a few changes. #insert teh codes here But it doesn't work! Please help. What can I do to debug the program by myself? ...
131
votes
16answers
89k views

Error installing mysql2: Failed to build gem native extension

I am having some problems when trying to install mysql2 gem for Rails. When I try to install it by running bundle install or gem install mysql2 it gives me the following error: Error installing ...
131
votes
4answers
52k views

Rails :include vs. :joins

This is more of a "why do things work this way" question rather than a "I don't know how to do this" question... So the gospel on pulling associated records that you know you're going to use is to ...
66
votes
4answers
20k views

How to prevent browser page caching in Rails

Ubuntu -> Apache -> Phusion Passenger -> Rails 2.3 The main part of my site reacts to your clicks. So, if you click on a link, it will send you on to the destination, and instantly regenerate your ...
121
votes
7answers
85k views

How do I parse JSON with Ruby on Rails?

I'm looking for a simple way to parse JSON, extract a value and write it into a db in Rails. Explicitly what I'm looking for is a way to extract a shortUrl from the JSON returned from the bit.ly API: ...
78
votes
19answers
42k views

Should I learn Ruby or Python? [closed]

I'm a C(++)/C# programmer and I would like to learn a scripting language to create small tools (text processing, build scripts, a little web development, etc). I would like to learn either Ruby or ...
116
votes
6answers
16k views

What is Ruby's double-colon (::) all about?

I'd probably be able to answer this for myself if :: wasn't so hard to Google. Didn't see anything on SO so thought I'd try my luck. What is this double-colon :: all about? I see it everywhere in ...

1 2 3 4 5 520
15 30 50 per page