May 12, 2013

cancan considered harmful

TL;DR overwrite as_json on all your CanCan Ability classes. Since I’ve started using squash for bug tracking I started noticing exceptions which prevented squash client from transmitting exceptions to the squash backend. The exceptions squash was rescueing made squash raise a new exception! Digging through the stack traces it became obvious that Ryan Bates cancan is the root of all evil. To reproduce fire up irb and paste the following lines: Read more

May 6, 2013

syncing database content with mina

Imagine you are working on an application which is already in production, or being used by a lot of people. While you’re working on a new version, problems occur in production, which are hard to reproduce for you because all you’ve got on your local machine is a static dataset. Often you’ll find yourself creating database dumps from production and importing them on your local machine. A repetitive and somewhat time consuming task. Read more

March 29, 2013

Asset Pipeline and I18n using i18next

About one year ago I wrote about i18n and the rails asset pipeline with jQuery. Last week I took the time to update my jquery-localization-engine to support i18next instead of jquery-localize. I also added support for an external service, Copycopter. Copycopter enables you to update your localizations without being forced to redeploy your application. The new package is called rails-asset-localization. So far it’s working really great. To summarize - the upsides Read more

March 15, 2013

Dynamic Model validations with Ruby on Rails

Ruby on Rails 3 made dynamic validations really easy. Yet I feel like most people follow bad advice when implementing dynamic validations in rails. If you read posts on Stackoverflow you’ll find something like this: class Project < ActiveRecord::Base validates_presence_of :name, if: :name_should_be_present attr_accessor :name_should_be_present end # ... class ProjectsController < ApplicationController def create @project = Project.new(params) @project.name_should_be_present = true if @project.save # snip else # snap end end end The more complex your validations get e. Read more

February 16, 2013

deploying with mina & current git revision

At the time of writing mina does not support writing a REVISION file on deployment, like capistrano does by default. Mina also deletes the .git directory at the end of each deployment, leaving you no option to access your git log to retrieve the currently deployed revision (note that this might change in the future). Luckily, most software that depends on your app running out of a git revisioned directory, like for example squash, support fallback modes which rely on your REVISION file existing somewhere. Read more

February 11, 2013

Automate commands using AutomatedCommands

Since DHH released commands some months ago I was thinking about how to properly automated this so one does not have to manually run test "unit" and similar every time you change a file. The result is AutomatedCommands. A combination of a simple rake task and named pipes to communicate with your rails instance. So how does it work, exactly? First commands: commands enables you to run your TestUnit tests from within your rails console, if you are running the console in test environment. Read more

February 6, 2013

phased-restarts using puma

In my original post about zero downtime deployments I wanted to use puma. At the time of writing puma did not support zero downtime restarts: while the connection was kept alive, all workers were killed at once so no requests could be served until the new workers had fully started up. This changed as of puma v2.0.0.b6. Now you can send SIGUSR1 to the puma master process and puma will phase out old workers while starting new workers one at a time. Read more

February 3, 2013

say hello to url_plumber

Last week I solved a recurring problem in my job as a software developer: Combining different parts of a user interface which all need to change the URL parameters to work properly. The Problem Take for a example a dataset presented using a paginated table. The table can be ordered using any of the displayed columns and the dataset can be filtered using a form and some links. The resulting URL could consist of the following parameters: Read more

January 20, 2013

iced-rails released

I’ve been playing around with IcedCoffeeScript for a while now and wanted an easy integration with Ruby on Rails Asset Pipeline. The result is iced-rails. I decided to introduce the .iced file extension for IcedCoffeeScript, rather than overwriting .coffee even though IcedCoffeeScript is a superset of CoffeeScript. The Iced command line also defaults to .iced and I want to avoid surprises when using the gem. IcedCoffeeScript generates continuations to avoid callback pyramids by introducing two new keywords, await and defer. Read more

January 19, 2013

traq updated with bash-completion

Just recently traq reached v0.1. There have been three notable changes since its initial release: support for bash autocompletion. The setup instructions have been updated accordingly. the generated data files are now stored in a separate directory, which can be configured using the TRAQ_DATA_DIR environment variable. Pascal Hartig was kind enough to suggest this separation and also issued a pull request on github. the directory structure contains a new subdirectory, grouping entries by the year they were created in. Read more

© Raphael Randschau 2010 - 2022 | Impressum