Rails - Multi Language with Fast_Gettext

  • sudo gem install gettext --no-ri --no-rdoc
  • sudo gem install fast_gettext --no-ri --no-rdoc
  • script/plugin install git://github.com/grosser/gettext_i18n_rails.git (didn't work as gem)
  • environment.rb: see code example at the bottom
  • if this is your first translation: cp locale/app.pot locale/de/app.po for every locale you want to use
  • use method "_" like _('text') in your rails code
  • run rake gettext:find to let GetText find all translations used
  • translate messages in 'locale/de/app.po' (leave msgstr blank and ms...

Automatically build sprites with Lemonade

How it works

See the lemonade descriptions.

Unfortunately, the gem has a few problems:

  • it does not work with Sass2
  • it always generates all sprites when the sass file changes, which is too slow for big projects
  • it expects a folder structure quite different to our usual

All these problems are solved for us, in our own lemonade fork. This fork has since been merged to the original gem, maybe we can use t...

Using Passenger for development (with optional SSL)

  • install apache
  • sudo apt-get install ruby1.8-dev
  • sudo gem install passenger
  • sudo passenger-install-apache2-module
  • follow the instructions

Manually: configure a vhost in /etc/apache2/sites-available and link it to /etc/apache2/sites-enabled with something like the following
^
NameVirtualHost *:80

<VirtualHost *:80>
        ServerName application.local
        DocumentRoot /opt/application/public
        RailsEnv development
        RailsAllowModRewrite off
</VirtualHost>

<VirtualH...

Freeze (vendor, unpack) a single Ruby gem with and without Bundler

When you need to patch an existing gem, one way is to "vendor" the gem by copying it into the vendor/gems directory of your Rails project. You can then make any changes you require and Rails will use the vendored version of the gem after a server restart. Unfortunately you need to perform some additional steps to marry Rails and the copied gem. This notes describes what to do.

With Bundler

This is super-painful. If you just copy the gem to vendor/gems, Rails will complain:

Unpacked gem foolib in vendor/gems has no s...

How to install the date_performance gem

sudo gem install zip
git clone git://github.com/rtomayko/date-performance.git
cd date-performance
rake package:build
cd dist
sudo gem install --no-ri --no-rdoc date-performance-0.4.7.gem

Install a gem without RI and RDdoc

To improve installation times of gems you can use the following approach:

gem install xyz --no-document

To permanently ignore ri and rdoc when installing gems, add this line to ~/.gemrc:

gem: --no-document

Be aware that eliding local documentation may disable documentation support in your IDE.

Create an application with an older Rails version

sudo gem install rails --version="=1.2.3"
rails _1.2.3_ new-project-folder

Slugs with FriendlyId

Gem to provide nice looking urls ("/blog/the-greatest-bug-i-never-fixed"). If you don't need anything too special (like i18n for the urls) it works as a drop-in-replacement. It basically overwrites #to_param to return the slug, and .find to search by the slug.

Make sure, everywhere you build paths, you use model_path(:id => model) instead of model_path(:id => model.id). You also need to adapt all code using something like .find_by_id. The regular .find is fine.

See the github README for installation instructions.

Don't forget ...

Railscheck project home page

This project is (or will be) a best effort semi-static verifier for your Ruby on Rails projects. Delivered as a Ruby gem it provides a shell command task "railscheck" that you can run against your Rails projects to test for a number of typical bugs, potential problems and inconsistencies.

bundle-fu - Google Code

Web 2.0 sites have lots of tiny javascript/css files, which causes one extra round trip per file to the server and back! This is bad! Bundle-fu throws it all up into a big package and sends it out all at once.

The Exciter - Why You Should Deploy Your Next Application on Ruby 1.9 and a Rant in General

The rubyforge gems model may not be perfect, but damnit people, when there’s a gem update I know that it has actually been tested somewhat and it’s not just whatever random point HEAD happens to be at, at that point in time, by some random Joe who just bought TextMate.

roo

This gem allows you to access the content of

Sickill.net - Colorizing console output with Rainbow ruby gem

If you’re working on some cool ruby console-based application or just want to add a little style to your script here is a nice gem for you. It’s called Rainbow and it extends ruby String class adding methods to wrap the string with ANSI escape codes.

metric_fu: A Ruby Gem for Easy Metric Report Generation

Metric_fu is a set of rake tasks that make it easy to generate metrics reports. It uses Saikuro, Flog, Flay, Rcov, Reek, Roodi, Subversion, Git, and Rails built-in stats task to create a series of reports. It's designed to integrate easily with CruiseControl.rb by placing files in the Custom Build Artifacts folder.

Pennysmalls

I just released a gem to find image dimensions and type information fast.

Basement.org: On The Web, More Isn’t Only Less, It’s Actually Nothing

Amidst my 400 unread Boing Boing links are probably ten or fifteen that are probably real gems. But I’ll never know and Boing Boing sure as hell isn’t going to help me out.

Learning from the iPhone's failure as a gaming platform: gem-session.com blog

If we want mobile applications to stay around as a sustainable business, we need to be more honest about the strengths and weaknesses of a touchscreen UI, rather than salivating about an imaginary realm of unnamed possibilities.

From Bundler to Open and Inclusive Software Communities : Steven R. Baker

Though we ended up switching to what I consider to be a technically superior product based on simplicity, we arrived there because of poor community interaction on the part of the Bundler developers.

How to split a Ruby class into multiple source files - Gem Session

Unfortunately vanilla Ruby modules lack support for many idioms popular in modern Ruby. Most importantly, we have become accustomed to composing our classes with meta-programming macros such as has_many, validates_presence_of or after_save. And modules weren't built with macros in mind.

Never write a Cucumber step definition again with Cucumber Factory - Gem Session: gem

I love Cucumber, but I hate writing step definitions. They are ugly, awkward to write and very, very boring: Most step defintions merely create objects for a scenario to chew on.

michaeldv's awesome_print at master - GitHub

Pretty print your Ruby objects with style -- in full color and with proper indentation