What is OmniNerd?

Welcome! OmniNerd's content is generated by you, the reader. Through voting and moderation we strive to highlight the nerdiest of what's around and provide content that's a little more thought provoking than other sites.

Submit New Content

Voting Booth

I am most afraid of dying?

68 votes, 10 comments
3
Nerd-Its
+ -

Preserve Rails Ferret Index with a Symlink and Capistrano

Pencil blog by markmcb on 29 September 2007, tagged as ferret, index, capistrano, and rubyonrails

If you're deploying your Rails application with capistrano and using ferret as your app's index, you'll quickly notice that with every deployment/update to your production code will come a ferret index rebuild. Not good.

Luckily, the solution is quite simple.

First, deploy your app and build your index. Once that's done, copy your index folder to the shared folder:

cp -R /path/to/your/app/current/index /path/to/your/app/shared/

Lastly, in your deploy.rb file that you use to control your deployments, tell capistrano to create a symlink to the shared directory for your ferret index:

desc "Preserve ferret index" 
task :after_update_code, :roles => [:web] do
  run <<-EOF
    ln -s #{shared_path}/index #{latest_release}/index
  EOF
end

That's it. Now every time you deploy, your index is the same as it was before. This is great 99% of the time, but don't forget to rebuild your index manually if you modify your indexed data structures.

Star This to Save in Your Profile Favorite