Release 0.2 of BookmarkIt! Sidebar Plugin for Typo

Well, version 0.1 was shortlived. There was a critical difference between running with WEBrick and running in production environment with fastcgi.
The value of env[“REQUEST_URI”] did not contain “http://host”. So I found a quick solution and we’ll see if there is a better solution tomorrow.

Current solution consists of replacing

@article_url = request.env[“REQUEST_URI”]

with

@article_url = ‘http://’+request.env[“HTTP_HOST”]+
  request.env[“REQUEST_URI”]
  if @article_url.eql?(@article_url.gsub(/http:/,”).gsub(/HTTP:/,”))

You live and learn…

bookmarkit-0.2.zip and
bookmarkit-0.2.tgz

Allowing full access to a sub directory in Apache Server

I realize this is somewhat off topic here, but it wasn’t obvious to me, and it took quite a few google searches to come up a hints, so I thought someone might benefit from this.

I had what I thought was a pretty simple problem. I have a site that is currenlty protected by a password. You know, something like:

AuthType Basic
AuthName “Allow Specific Users”
AuthLDAPURL ldap://localhost:389/dc=domain,dc=com?uid?sub?(objectClass=*)
require valid-user

to protect the whole site. Now, I also needed a subdirectory to be accessible without a password.

That’s easy, I thought, I probably just need to create a or a .htaccess with AuthType None or something. Not so fast! After quite a while, I was starting to think that the only solution was going to be to set the root public, and protect all the sub directories but one.

But in fact the solution is very simple:

just create a .htaccess file and include:

Allow from all
Satisfy Any

And that’s it! Turns out Satisfy Any will let people in if either the require or the Allow matches.

Installing readline on Kubuntu

Running script/console provides the delightful answer:

/usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require’:
no such file to load – readline (LoadError)

Turns out that Kubuntu doesn’t have the curses libraries.

Here’s the begining of a solution

apt-get install libncurses5-dev libreadline5-dev (Ubuntu/Debian)

Then recompile the readline extension and go from there.

cd ext/readline
ruby extconf.rb
make
sudo make install

Read more

uninitialized constant SwitchTower (Capistrano?)

I did setup this blog (using the most excellent typo if you need to ask). The next step was to setup switchtower, and you guessed it, it almost worked. Here’s why.

Followed the directions to get it going and was ready to type my first command:

rake –trace remote_exec ACTION=setup

yeah, that would be too easy if it worked, wouldn’t it. Instead of the expected output, I get the very impolite:

** Invoke remote_exec (first_time)
** Execute remote_exec
rake aborted!
uninitialized constant SwitchTower
…/activesupport-1.2.5/lib/active_support/
dependencies.rb:200:in `const_missing’

I mean, I did not mean to be rude, so why is it doing this?

Sorry I can’t give credit to where credit is due (shame on me for not putting the info down at the time. Now that this is site is up and running, I can capture the next problem blow by blow as it happens). If you know who should get the credit, drop me a note. Anyway, here’s the solution.

in lib/taks/switchtower.rake replace


    begin
      require 'rubygems'
    rescue LoadError
      # no rubygems to load, so we fail silently
    end

    options = actions.last.is_a?(Hash) ? actions.pop : {}
to:

    begin
      require 'rubygems'
    rescue LoadError
      # no rubygems to load, so we fail silently
    end

    require 'switchtower/cli'

    options = actions.last.is_a?(Hash) ? actions.pop : {}

Incidentally, I did setup typo directly from svn to get the tagging extension builtin. And to use SwitchTower, I then commited this into my own subversion repository. This might get interesting the day I want to upgrade. We’ll keep this story for an other day.

Some non-transactional changed tables couldn’t be rolled back

Here’s an other thing that is not supposed to happen, but invariably does.

Playing aroung with Unit Testing in Rails (you are using them, right?), one test fails with:

Exception `ActiveRecord::StatementInvalid’ at
…/active_record/connection_adapters/mysql_adapter.rb:185
- Mysql::Error: Warning:  Some non-transactional changed
tables couldn’t be rolled back: ROLLBACK

Turns out that on my OS (debian), the default mysql database table type is MyISAM and it does not support ROLLBACK, try InnoDB instead.

March 12, 2006 update:

In case this is not possible, or too much problem, there is an other solution (albeit slower).

In test/test_helper.rb, change:

self.use_transactional_fixtures = true

to

self.use_transactional_fixtures = false

this way, the testing framework won’t use rollback but drop and recreate the tables each time (which explains why this is slower).

Missing default helper path

Here’s one of these things that can have you go huh?

So, here’s what happened. I created new rails app from scratch

rails ajax-test
script/generate ajax_scaffold Widget Widget
script/server

=> no page worked, only error was:

Controllers::RailsInfoController: missing default helper path
rails_info_helper when trying to access environment link

Thanks to John Martin in this post for the solution.

The solution indeed was to remove all /tmp/ruby_sess* files and restart WEBrick