Quantcast
Channel: iain.nl
Browsing all 133 articles
Browse latest View live
↧

Form Labels in Rails 2.2

Shamelessly copy-pasted from the README file of the new plugin I released today: Since form labels don’t use I18n in Rails 2.2 (I was too late in submitting the patch), we’d have to make due with a...

View Article


acts_as_translatable_model plugin

After a long day in the train today, I extracted the I18n functionality from ActiveRecord so its applicable to any class. This can be especially handy if the source of the data is different, e.g. LDAP....

View Article


Resources

Just a simple little advice for all RESTful programmers out there. It's really simple, and cleans up your code quite a bit. A lot of Rails applications have two roles: an admin and non admin. Your code...

View Article

Localizing Dates and Times in Rails 2.2

Here is the next installment of a series of guides I'm writing for internationalizing a Rails 2.2 application. Please read the first part, Translating ActiveRecord, if you haven't already. This time...

View Article

Pluralization Rails 2.2 style

Railscast episode 132 talks about using helpers outside views. All in all a good and useful screencast. I only have one comment: In Rails 2.2 internationalized pluralization goes like this:...

View Article


Asset paths

Just a quickie. We all know that Rails adds asset ids to images, javascript include tags and stylesheet link tags. This is to help the browser in caching assets properly. The generated code looks...

View Article

AuthLogic is awesome!

Probably every Rails developer has used restful_authentication. Most of us on practically every application. But restful_authentication generates quite some code and is somewhat an odd plugin. It is a...

View Article

no_value_helper plugin

It took some late night coding, but I finished another plugin. It's a little helper that goes by the name of no_value_helper. To install it, type: ./script/plugin install...

View Article


Chainable.not.gem

Well then: happy holidays! This x-mas, there have been a few nice Ruby presents, like the merging of Rails with Merb and Github has a shiny new feature for creating project sites. I too will present...

View Article


RSpec, Shoulda, and custom matchers

I have been playing with the matchers that Thoughtbot's Shoulda provides, and they are very cute! For instance, a controller can be easily tested like this: describe ArticlesController do...

View Article

Gem cleanup

I was browsing through the gem documentation today, and I found a command that I didn't know existed. sudo gem cleanup It removes old versions of your installed gems. You can of course specify the gems...

View Article

Nested Forms

The old subject of nested forms comes back again to hunt me. Rails 2.3 has the new and shiny accepts_nested_attributes_for feature. I like it, but there are some things to take into consideration....

View Article

Writing YAML files

A short one for today: How do I write YAML files? Well, to get the prettiest results, I do something like this: def write(filename, hash) File.open(filename, "w") do |f| f.write(yaml(hash)) end end def...

View Article


Filtering with named scopes

Suppose you have an index page with people and you want to have a series of neat filters to show a selection of people. For example only the people still alive of only the adults. How would one do...

View Article

Filtering with named scopes (encore)

In my previous post, I talked about making filters using named scopes. To summorize: I like the method of using a named_scope and delegating to specified filters. This way, you can structure your...

View Article


Silencing Passenger

When using Rails 2.3 and Passenger, you can do yourself a favor by adding this line to config/silencers/backtrace_silencer.rb Rails.backtrace_cleaner.add_silencer { |line| line =~ /^\s*passenger/ }...

View Article

Image may be NSFW.
Clik here to view.

Plugin release: Root table

Yes, I've written another plugin for Rails. It's about so called root tables. It seem to be making them often. I want a list with options to choose from and some easy way to manage that list, which is...

View Article


Configuring Autotest

I have a big test suite in the current Rails application I'm working on. I have 2340 examples in RSpec, taking over 2 minutes to run. This is an absolute pain to run. Luckily there is autotest (or...

View Article

Prawn and controller tests

There is a real annoying gotcha in using controller tests to test an action that renders a pdf with Prawn. You'll get a NoMethodException on "nil.downcase". The troubling part is that it totally puts...

View Article

Cucumber 0.5 and my little commit

The strangest thing happened to me this week. I was working on a little side project at work. It seemed like a nice time to try out some new gems (Bundler and Devise: love it! InheritedResources, not...

View Article
Browsing all 133 articles
Browse latest View live