Is the ruby operator ||= intelligent?

I have a question regarding the ||= statement in ruby and this is of particular interest to me as I’m using it to write to memcache. What I’m wondering is, does ||= check the receiver first to see if it’s set before calling that setter, or is it literally an alias to x = x […]

How can I switch to ruby 1.9.3 installed using Homebrew?

I have installed ruby 1.9.3 using hombrew brew install ruby But default 1.8.7 is still used. How can I switch osx to use 1.9.3 as default ruby?

specify db in gemfile rails app

I want to use postgres db for my local and production environment both. How should my gemfile look like for this case? Should I completely remove sqlite and just put gem pg or the development and production environment is required with pg? Please help.

How to scrape specific strings

I want to scrape a website, for the terms (“cats”, “dogs”, “zebra”), how do I do this? I want it the result to be all the instances of the given string, & maybe even a count. I could only find ways to do it by tags, but not inside of the tags. What program or […]

What's the difference between a proc and a lambda in Ruby?

And when would you use one rather than the other?

How to break out from a ruby block?

Here is Bar#do_things: class Bar def do_things Foo.some_method(x) do |x| y = x.do_something return y_is_bad if y.bad? # how do i tell it to stop and return do_things? y.do_something_else end keep_doing_more_things end end And here is Foo#some_method: class Foo def self.some_method(targets, &block) targets.each do |target| begin r = yield(target) rescue failed << target end end […]

Ruby ampersand colon shortcut

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| } That is, &:foo creates the block { |obj| }, turns it into a Proc, and passes it to each. Why does this work? Is it just a Ruby […]

centos 6 vps ruby rake issue

I am using vps centos6, ruby 1.8.7 and gem 1.3.7 when I do rake db:migrate –trace following error appear ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment rake aborted! no such file to load — readline /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original _require’ /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’ /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/depende ncies.rb:156:in `require’ /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/depende ncies.rb:521:in `new_constants_in’ /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/depende ncies.rb:156:in `require’ /usr/local/lib/ruby/gems/1.8/gems/rush-0.6.8/lib/rush/shell.rb:1 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in […]

sqlite3-ruby install error on Ubuntu

I have the following error during sqlite3-ruby install: Building native extensions. This could take a while… ERROR: Error installing sqlite3-ruby: ERROR: Failed to build gem native extension. /usr/bin/ruby1.8 extconf.rb checking for sqlite3.h… no sqlite3.h is missing. Try ‘port install sqlite3 +universal’ or ‘yum install sqlite3-devel’ *** extconf.rb failed *** Could not create Makefile due to […]

Kitchen test not running

I was trying to run kitchen list and it was showing gem conflict between mixlib-shellout v2.1.0 and v2.2.6. Until yesterday everything was running fine and i have no idea from where this conflict arises. This is the error i was getting I, [2016-04-06T23:01:16.707167 #5551] INFO — Kitchen: —–> Starting Kitchen (v1.4.2) E, [2016-04-06T23:01:16.722778 #5551] ERROR […]

Ruby is the best programming language in the world - Ruby on Rails.