Declare different CSS background-images for different locales

Posted Over 12 years ago.

If you would like to use language specific layout (e.g. background-images) in your applications stylesheets you can achieve this...

Login forms: Disable browser prompt to remember the password

Posted Over 12 years ago by Henning Koch.

In order to prevent the browser from asking whether to remember the password, give a form an autocomplete attribute with...

Large forms are slow on the iPad

Posted Over 12 years ago by Henning Koch.

Forms with many inputs (600+ in my case) become extremely unresponsive on an iPad, up to the point where it...

Multi-line Ruby block in Haml

Posted Over 12 years ago by Henning Koch.

There are several options, but most of them are impractical. The best way is to use the :ruby filter:

How to use html_safe correctly

Posted Over 12 years ago by Henning Koch.

Back in the war, Rails developers had to manually HTML-escape user-supplied text before it was rendered in a...

Micro clearfix mixin for Sass

Posted Over 12 years ago by Henning Koch.

Clearfix is a hack to clear floating elements without additional HTML markup. If you only need to support IE8 and...

Stub methods on any instance of a class in Rspec 1 and Rspec 2

Posted Over 12 years ago by Henning Koch.

RSpec 1 (Rails 2) With the most recent spec_candy.rb helpers you can say: User.stub_any_instance(:foo => :bar) user = User.new...

Fix multiple CKEditor instances using jQuery adapter - fixed since 4.2

Posted Over 12 years ago.
ckeditor.com

Using the jQuery adapter breaks the built-in save function of CKEditor. Phenomenon: The page is submitted correctly, but the...

How to change the order of nested forms being rendered (especially blank forms)

Posted Over 12 years ago.

Generally for nested forms, a blank form is placed below all other existing object forms. If you would like to...

Making the rails 3.1. asset pipeline and asset precompiling work in production mode

Posted Over 12 years ago by Christoph Beck.
blog.bitcrowd.net

Recently, we had an interesting lunch-break with the rails 3.1. asset-pipeline in production mode. Daniel Zahn made a...

Test that a form field has an error with Cucumber and Capybara

Posted Over 12 years ago by Henning Koch.

You can use the step definition below to say this: Then the "Last name" field should have an error

Using heredoc for prettier Ruby code

Posted Over 12 years ago by Arne Hartherz.

You can use heredoc to avoid endlessly long lines of code that nobody can read. Heredoc strings preserve linebreaks and...

Rendering a custom 404 page in Rails 2

Posted Over 12 years ago by Dominik Schöler.

Simple: Tell the application controller how to handle exceptions, here a RecordNotFound error. Do this with the following line: # application_controller.rb...

Let a Rails 3 application make a request to itself

Posted Over 12 years ago by Henning Koch.

Ever wondered how Rails talks to itself in a Cucumber feature? In Rails 3 you can do it like this...

When Rails no longer renders changes in view templates or Sass stylesheets

Posted Over 12 years ago by Henning Koch.

Do you have page caching enabled for the development environment and there are cached pages lying around in public/?

Fix: "undefined method `bytesize' for #<Array>"

Posted Over 12 years ago by Henning Koch.

I believe that when WEBrick has trouble bringing up your Rails application, the WEBrick component that is supposed to print...

How to use Rails URL helpers in any Ruby class

Posted Over 12 years ago by Henning Koch.

If you have any class which requires access to some path methods generated by your routes. Even though you could...

Invoices: How to properly round and calculate totals

Posted Over 12 years ago by Henning Koch.

While it might seem trivial to implement an invoice that sums up items and shows net, gross and vat totals...

Always show all form errors during development

Posted Over 12 years ago by Henning Koch.

You've been there: A form cannot be submitted, but you don't see a validation error because the field...

Distance of time in what you like: days, months, years

Posted Over 12 years ago by Dominik Schöler.

Sometimes the Rails helper #distance_of_time_in_words is using too much magic. When you need a time difference...

How to make a single check box (or image, etc) align vertically

Posted Almost 13 years ago by Arne Hartherz.

Consider this HTML: Even though the surrounding container defines a line-height, which vertically centers its inline elements, the check...

Ruby GetText will eval scripts containing ActiveRecord classes

Posted Almost 13 years ago by Arne Hartherz.

When the Ruby parser module of Ruby-GetText comes across a file in one of its search directories (e.g. lib/scripts...

Detect the current Rails environment from JavaScript or CSS

Posted Almost 13 years ago by Henning Koch.

Detecting if a Javascript is running under Selenium WebDriver is super-painful. It's much easier to detect the current...

How to stub class constants in RSpec

Posted Almost 13 years ago by Dominik Schöler.

Hint: There's another card with this helper for Cucumber features. Sometimes you feel like you need to stub some...