All Questions

103
votes
5answers
15019 views

Is there any difference between the `:key => "value"` and `key: "value"` hash notations?

Is there any difference between :key => "value" (hashrocket) and key: "value" (Ruby 1.9) notations? If not, then I would like to use key: "value" notation. Is there a gem that helps me to convert ...
99
votes
10answers
46825 views

Ruby Gem install Json fails on Mavericks and Xcode 5.1 - unknown argument: '-multiply_definedsuppress'

I was trying run gem install json and got the following error Gem::Ext::BuildError: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ru...
260
votes
36answers
224906 views

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

I am using Authlogic-Connect for third party logins. After running appropriate migrations, Twitter/Google/yahoo logins seem to work fine but the facebook login throws exception: SSL_connect returned=...
23
votes
2answers
7156 views

Why is "slurping" a file not a good practice?

Why is "slurping" a file not a good practice for normal text-file I/O, and when is it useful? For example, why shouldn't I use these? File.read('/path/to/text.txt').lines.each do |line| # do somet...
92
votes
12answers
68435 views

ExecJS::RuntimeError on Windows trying to follow rubytutorial

UPDATE: Colin's suggestion of removing the line //= require_tree . has fixed the issue. I have wasted over 2 days trying to follow every suggestion out there and fix my issue. I am trying to follow t...
834
votes
10answers
154171 views

Understanding the Rails Authenticity Token

I am running into some issues regarding the Authenticity Token in Rails, as I have many times now. But I really don't want to just solve this problem and go on. I would really like to understand the ...
66
votes
5answers
44808 views

How to call methods dynamically based on their name?

How can I call a method dynamically when its name is contained in a string variable? For example: class MyClass def foo; end def bar; end end obj = MyClass.new str = get_data_from_user # e.g. `...
350
votes
3answers
62827 views

When monkey patching a method, can you call the overridden method from the new implementation?

Say I am monkey patching a method in a class, how could I call the overridden method from the overriding method? I.e. Something a bit like super E.g. class Foo def bar() "Hello" end end c...
414
votes
10answers
102354 views

Why are exclamation marks used in Ruby methods?

In Ruby some methods have a question mark (?) that ask a question like include? that ask if the object in question is included, this then returns a true/false. But why do some methods have exclamatio...
168
votes
3answers
97557 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 sergio@sergio...

Previous Next