At EuroOSCON
Here’s a nice picture of us at EuroOSCON. I’m the one with the glasses, Manfred is the slightly fuzzier fellow wearing the brown shirt.
Photo by James Duncan Davidson/O’Reilly Media
Here’s a nice picture of us at EuroOSCON. I’m the one with the glasses, Manfred is the slightly fuzzier fellow wearing the brown shirt.
Photo by James Duncan Davidson/O’Reilly Media
We’re currently redesigning our site, so you might need to hit the reload button when things appear to be broken.
For the last few months I’ve been using TextMate on my iBook and on the Lil’ Mac at work. I’ve grown accustomed to the various ‘insert snippet’ commands available in TextMate. Unfortunately Vim doesn’t have these commands and I find myself inserting ^Z in my views.
However, Vim configuration is powerful enough to implement these commands. Make sure you’re in command mode and do the following:
:imap <C-z> <lt>%= %><Left><Left><Left>
:imap <C-x> <lt>% %><Left><Left><Left>
This will allow you to insert <%= %> and <% %> into your files during insert mode. It is also possible to insert these commands in ~/.vimrc so you don’t have to define them every time you launch vim.
You can find the other mapping syntax rules on the vim.org website and in your vim help files.
As most of you already know, Switchtower is a very nice way to deploy your Rails application.
When I tried to deploy one of Thijs’ applications using Switchtower, I ran into some trouble. Switchtower tried to chmod 666 the log file, but the log file was owned by thijs:thijs.
Jamis Buck asked me to submit this bug to the Rails trac site, so I did just that. To solve the problem for the time being, I added the following to my deploy configuration:
desc "Change permission of the project to avoid problems" +
"with source.checkout and symlink"
task :before_update_code do
sudo "chown -R $USER #{deploy_to}"
end
desc "Set permissions on files so the webserver can work with the files"
task :after_symlink do
sudo "chgrp -R www-data #{shared_path}/log"
sudo "chgrp -R www-data #{shared_path}/system"
end
If you want to use this hack, make sure you change www-data to the group your webserver/application server runs under. If you’re running Debian or Ubuntu, this should work. Make sure any other directories the webserver needs to write to, like page cache directories, are also properly chgrp’d.
Test are supposed to be run often, but they only get run if they’re easy to run. When you create a plugin in your Ruby on Rails project, it doens’t get run by default.
And that’s not very easy now, is it? Fortunately there is a standard task to run the plugin tests, which is called `test_plugins’. How do we get this task to run all the time?
RoR allows us to specify our own tasks in /lib/tasks, so we’re going to add a file called `test_plugins_by_default.rake’ to this directory, and we put the following in the file:
desc "Run test:plugins by default."
task :default do
namespace 'test' do
Rake::Task[:plugins].invoke
end
end
Very well sir, but why does this work? The Rake User Guide tells us that a task that is declared multiple times, cumulatively adds it’s actions to the task. So ‘test_plugins’ will now be run in the default task.