After I upgraded my Mac to Snow Leopard, Capistrano deployments with key forwarding stopped working. I started getting a following error:
Permission denied (publickey).
My fellow Bambinos enlightened me that key forwarding was switched off by default in Snow Leopard. The solution was to change the following two lines in /etc/ssh_config:
#Host *
#ForwardAgent no
to the following two lines:
Host *
ForwardAgent yes
Unfortunately after this change I was still getting Permission denied (publickey) error.
Today I found the root cause. My ssh key was not added to the authentication agent so the key was not forwarded. The solution was to execute the following command:
ssh-add ~/.ssh/id_dsa
(or ssh-add ~/.ssh/id_rsa if you use rsa key)
Now everything works fine.
./script/generate paperclip MODEL_NAME ATTACHMENT_NAME
example:
./script/generate paperclip video source
GENERATES:
add_attachments_source_to_video.rb
class AddAttachmentsSourceToVideo < ActiveRecord::Migration
def self.up
add_column :video, :source_file_name, :string
add_column :video, :source_content_type, :string
add_column :video, :source_file_size, :integer
end
def self.down
remove_column :video, :source_file_name
remove_column :video, :source_content_type
remove_column :video, :source_file_size
end
end
I recently needed to understand how beanstalkd works and how does it implement the distributed behaviour, so I did some reading.
From the beanstalkd main page:
beanstalkd is a fast, distributed, in-memory workqueue service
Ok, it is a distributed service, so let’s find some more info about its distributed nature.
This is what we can find in beanstalkd FAQ:
Does beanstalk inherently support distributed servers?
Yes, although this is handled by the clients, just as with memcached. The beanstalkd server doesn’t know anything about other beanstalkd instances that are running.
Using the same argumentation I could say that FTP or any database server is also distributed if you only start more than one instance.
The fact some server allows to create scalable and distributed solutions, doesn’t necessarily mean that they are distributed on their own.
Here is how to run Haml’s unorthodox plugin generator method using Rails Templates:
Here is a sample Rails Template for fun:
The alternative, and traditional method of ruinning software projects is called “waterfall”
module Foo
def self.included(base)
base.show_action(:custom_action)
end
def custom_action
"foo"
end
end
git add -u
This deletes all removed files from git.
resources_controller takes you a long way into simplifying your controllers. Still, whenever you need to add custom collection or member routes to your app you’re out in the wild again. This snippet of code uses a combination of ActiveRecord’s named_scopes and resources_controller to simplify those custom actions. With a bit more of abtraction it could be turned into library code that you test once and reuse as many times as you want in different codebases.
The cool thing is that we get seamless nested controllers if we need them, such as in /posts or /users/2/posts