HowTo: Phusion Passenger aka mod_rails for Apache

August 8th, 2008Posted by benediktFiled in Articles, Linux, Ruby, Ruby on Rails

Yesterday I decided to give Phusion Passenger aka mod_rails a try and installed it. It was dead simple to set it up and to deploy rails applications with it. I’m now using it for several “small” applications, for which the whole overhead of setting up a cluster of mongrels and a proxy doesn’t seem to be adequate. I’ll give you a short summary on how to install mod_rails for apache2 on Debian Etch.

First, install the passenger gem using RubyGems (if you don’t have Ruby and RubyGems running on your server, install them first – of course):

   1  gem install passenger

Afterwards, run the passenger apache2 module installer using this command:

   1  passenger-install-apache2-module

It’ll check for the required software to install the module, compile it and copy it to the correct folders. If some software is missing install it using aptitude (ie. aptitude install g++ if you’re missing the GNU C++ Compiler).

Next, create two new files in the /etc/apache2/mods-available directory. One called mod_rails.load:

   1  LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.2/ext/apache2/mod_passenger.so

... and the other one called mod_rails.conf:

   1  PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.2
   2  PassengerRuby /usr/bin/ruby1.8

Now you can enable the module using a2enmod and restart apache.

   1  a2enmod mod_rails
   2  apache2ctl restart

That’s it! Now simply deploy your rails application, just make sure apache’s document root is pointing to your applications public folder. Passenger will automatically detect your rails application and start up processes as needed. You can check it’s status and stats using the passenger-status and passenger-memory-stats commands. For more details on mod_rails, take a look at it’s documentation.

My day-to-day resources on Ruby and Rails

August 4th, 2008Posted by benediktFiled in Articles, Ruby, Ruby on Rails

News

I try to keep up with Ruby and Ruby on Rails, even if I’m not working with one of them at the moment. These are the three feeds helping me to get the latest news:

PlanetRubyOnRails.com, not to be mixed up with PlanetRubyOnRails.org, is a simple feed aggregator with a set of quite informative blogs. Including the official Riding Rails Blog, Ruby Inside, and InfoQ. Unfortunately it doesn’t provide an RSS-Feed anymore, but thanks to Feed43 it’s easy to build one on your own.

Every Wednesday Gregg Pollack and Jason Seifer of Rails Envy publish their Rails Envy Podcast, covering last week’s most important topics in the Ruby and Rails community. They’re giving a short summary for every topic, together with a link in their shownotes and usually are fooling around. The podcast’s length is usually between 10 to 15 minutes.

RubyOnRails-Ug Planet

Just like PlanetRubyOnRails, the planet of the german ruby on rails usergroup is a feed aggregator, except it includes blogs of members of the german Ruby on Rails community. (Yes, mine too …) Its far from being as active as the international one, but usually includes interesting posts.

Documentation

When I’m working on Ruby and Ruby on Rails code, I use there resources to quickly look up documentation:

Ruby-Doc.org provides the documentation for both Ruby’s Core and Stdlib. The documentation is in the default RDoc format, so I usually end up hitting [Strg]+[F] and using my browsers search function to quickly get to the relevant sections.

api.rubyonrails.com

What Ruby-Doc.org is for ruby, api.rubyonrails.com is for rails. It’s the standard rails documentation in the default RDoc format. As with Ruby-Doc.org I use my browsers search to quickly find what I’m looking for.

Rails-Doc.org is a quite new site providing the full rails documentation. Unlike the default API documentation site (see above) it also includes documentation of older rails versions. Additionally it has a nice search engine, and adds the ability to post notes. There are other sites providing similar functionality for the rails documentation, but somehow Rails-Doc.org just feels right and I’m using more and more.

Gem Server

Did you know the fabulous RubyGem-Tools provide a server including the documentation for all your installed gems? Simple run gem server on the console, fire up your browser and navigate to http://localhost:8808. Okay, it’s just the standard RDoc documentation for each gem, without any fancy search or anything … but who cares if you’re somewhere in the middle of nowhere with no internet connection? :-)

Other

Last but definitely not least, are the RailsCasts by Ryan Bates. Every Monday he publishes a approx. 5 to 10 minute screencast on a variety of topics related to rails development. If you haven’t seen one of them yet, don’t hesitate any longer. Ryan’s explanations are concise and based on practical examples.

What are your resources on Ruby / Rails? Which blogs are you reading to stay up-to-date? Which documentation are you using? I’m interested in your comments (there are way to few anyways … ;-))!

Update (Aug 15.)

Nodeta, creators of Rails-Doc.org, released APIdock yesterday. APIdock extends the Rails-Doc.org concept to multiple projects. Currently Rails, Ruby and RSpec are included.

Script.aculo.us should have Effect.Emerge

July 24th, 2008Posted by benediktFiled in Javascript

Script.aculo.us includes a nice effect called Effect.DropOut, which let’s the element fall in an “invisible trap” underneath. Surprisingly there isn’t an opposite effect. Calling Effect.DropOut with Effect.Transitions.reverse as transition, doesn’t work either. So what to do? Effect.Emerge to the rescue!

   1  
   2  Effect.Emerge = function(element) {
   3    element = $(element);
   4    var oldStyle = {
   5      top: element.getStyle('top'),
   6      left: element.getStyle('left') };
   7    var position = element.positionedOffset();
   8    return new Effect.Parallel(
   9      [ new Effect.Move(element, {x: 0, y: -100, sync: true }), 
  10        new Effect.Opacity(element, { sync: true, from: 0.0, to: 1.0 }) ],
  11      Object.extend(
  12        { duration: 0.5,
  13          beforeSetup: function(effect) {
  14            effect.effects[0].element.show().makePositioned().setStyle( { top: (position.top + 100) + 'px' }); 
  15          },
  16          afterFinishInternal: function(effect) {
  17            effect.effects[0].element.undoPositioned().setStyle(oldStyle);
  18          } 
  19        }, arguments[1] || { }));
  20  };

Basically it’s just a modified version of Effect.DropOut to reverse the effect. Try it in compination with Effect.multiple ... :-)

So I gave a talk ...

July 2nd, 2008Posted by benediktFiled in Other

... and messed it up.

Last week I’ve been giving a talk (in german) about the project I did during my internship at the Human Computer Interaction Research Center at the university of applied sciences Fulda. This was the first talk I gave (not counting those I had to do in school and for university) and of course it ended up a little awkward. I didn’t intend to do a live demo at the end but somehow I changed my mind during the presentation. Of course nothing worked like expected … ;-) Lessons learned for next time. If you’d like to see the disaster yourself there is a video available.

I love TeX

May 19th, 2008Posted by benediktFiled in Other

I got my thesis’ topic last week and will start to write it within the next few days. I decided to write it using TeX as all my attempts to write large documents in OpenOffice.org caused very bad headaches. The TeX approach fits my needs much better and I can use GIT much more effectively to manage the changes to the documents. With TeX I could even apply patches to the document … how cool is that? :-) Just imagine sending the document to someone else for proofreading and getting back a patch that can be instantly applied without having to search every passage that had misspelled words in it. Maybe I’ll post some links that helped me getting into all the TeX stuff in the near future.