Gem needs to append column to passed model

I cannot find out how to have my gem append a column to an existing model/table. My gem needs to check the created_at attribute of a model, and based on time passed, set an active column from true to false. I’m assuming that, upon install, it will end up needing a $ rails {gem_name}:install type […]

paperclip-dropbox gem throws wrong argument type

I’m trying to use the paperclip-dropbox gem here, and I’m having issues with the setup and passing my credentials. In the documentation, the setup in the model is done like so: class User < ActiveRecord::Base has_attached_file :avatar, :storage => :dropbox, :dropbox_credentials => “#{Rails.root}/config/dropbox.yml”, :dropbox_options => {…} end I have configured my dropbox.yml file and put […]

Why is this RMagick call generating a segmentation fault?

I’ve been banging my head against the wall for the better part of an hour trying to figure out what’s going wrong here, and I’m sure (or rather hoping) it’s something fairly obvious that I’m overlooking. I’m using Ruby 1.9.1, Sinatra 1.0, and RMagick 2.13.1. ImageMagick and RMagick are correctly installed and functional—I’ve successfully manipulated […]

Avoiding AppleScript through Ruby: rb-appscript or rubyosa?

Hello fellow Mac rubyists and AppleScript haters, For those of you that have experience with both rubyosa and rb-appscript, I’d like the hear the pros and cons of each, which one you decided to stick with, and which one you’d recommend for a totally non-AppleScript savvy ruby old-timer. Also, are there any other options that […]

How can I track system-specific config files in a repo/project?

I have a ruby project, and the database host and port might be different on dev and production. I need a way to get different values for those into my scripts for the two environments. The project should be complete – so there should be some way to specify default values. I don’t want a […]

How to understand symbols in Ruby

Despite reading “Understanding Ruby Symbols”, I’m still confused by the representation of the data in memory when it comes to using symbols. If a symbol, two of them contained in different objects, exist in the same memory location, then how is it that they contain different values? I’d have expected the same memory location to […]

Calling shell commands from Ruby

How do I call shell commands from inside of a Ruby program? How do I then get output from these commands back into Ruby?

How do I copy a hash in Ruby?

I’ll admit that I’m a bit of a ruby newbie (writing rake scripts, now). In most languages, copy constructors are easy to find. Half an hour of searching didn’t find it in ruby. I want to create a copy of the hash so that I can modify it without affecting the original instance. Some expected […]

Look up all descendants of a class in Ruby

I can easily ascend the class hierarchy in Ruby: String.ancestors # [String, Enumerable, Comparable, Object, Kernel] Enumerable.ancestors # [Enumerable] Comparable.ancestors # [Comparable] Object.ancestors # [Object, Kernel] Kernel.ancestors # [Kernel] Is there any way to descend the hierarchy as well? I’d like to do this Animal.descendants # [Dog, Cat, Human, …] Dog.descendants # [Labrador, GreatDane, Airedale, […]

Automatic counter in Ruby for each?

I want to use a for-each and a counter: i=0 for blah in blahs puts i.to_s + ” ” + blah i+=1 end Is there a better way to do it? Note: I don’t know if blahs is an array or a hash, but having to do blahs[i] wouldn’t make it much sexier. Also I’d […]

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