How do I fix the “You don’t have write permissions into the /usr/bin directory” error when installing Rails?

I’m trying to install Rails 3 on a brand new MacBook Pro running OS X 10.6.3, Ruby 1.8.7, and Rails 2.3.5 and I’m wondering if I’ve hosed myself. So far, I’ve run these commands: $ gem update –system $ gem install arel tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n $ … Read more

Repairing Postgresql after upgrading to OSX 10.7 Lion

I recently upgraded to OSX 10.7, at which point my rails installation completely borked when trying to connect to the psql server. When I do it from the command line using psql -U postgres it works totally fine, but when I try to run the rails server or console with the same username and password, … Read more

What is the right way to override a setter method in Ruby on Rails?

I am using Ruby on Rails 3.2.2 and I would like to know if the following is a “proper”https://stackoverflow.com/”correct”https://stackoverflow.com/”sure” way to override a setter method for a my class attribute. attr_accessible :attribute_name def attribute_name=(value) … # Some custom operation. self[:attribute_name] = value end The above code seems to work as expected. However, I would like … Read more

Understanding :source option of has_one/has_many through of Rails

Please help me in understanding the :source option of has_one/has_many :through association. The Rails API explanation makes very little sense to me. “Specifies the source association name used by has_many :through => :queries. Only use it if the name cannot be inferred from the association. has_many :subscribers, :through => :subscriptions will look for either :subscribers … Read more