Inspect the page content in a Cucumber session

Posted Over 13 years ago by Arne Hartherz.

When you need to see the content of a page (i.e. not all the HTML but the relevant text body...

Check if a field or button is disabled with Cucumber

Posted Over 13 years ago by Arne Hartherz.

Using this step definition you can check if any form field (text field, checkbox, etc) or button is disabled:

Encode or decode HTML entities

Posted Over 13 years ago by Henning Koch.

Use the htmlentities gem. Encoding works like this: require 'htmlentities' coder = HTMLEntities.new string = "<élan>" coder.encode(string) # => "&lt;élan&gt;"

Virtual attributes for array fields

Posted Over 13 years ago by Henning Koch.

When a has_many association basically serves to store a list of associated strings (tags, categories, ...), it can be convenient...

Virtual attributes for integer fields

Posted Over 13 years ago by Henning Koch.

Note that this card is very old. You might want to use ActiveType for your auto-coerced virtual attributes instead...

Manipulate an array attribute using multiple check boxes

Posted Over 13 years ago by Henning Koch.
apidock.com

E.g. when you're using a tagging gem, you have seen virtual attributes that get and set a string array...

Test that a select option is selected with Cucumber

Posted Over 13 years ago by Henning Koch.
macksmind.net

This step tests whether a given select option comes preselected in the HTML. There is another step to test that...

Useful collection of Sass mixins

Posted Over 13 years ago by Arne Hartherz.

This collection of Sass mixins enables cross-browser styling (including IE with CSS3PIE) with less lines of code.

Problems with Rails 3 Remote Links and Forms Using jQuery .live() in IE

Posted Over 13 years ago by Lexy.
alfajango.com

There is a problem with AJAX response handling for Rails 3 remote links and forms in Internet Explorer. This problem...

Aliases for routes

Posted Over 13 years ago by Tobias Kraze.

The following initializer provides an :alias => "my_route_name" option to restful routes in your route.rb. This simply makes the...

Generate a Unicode nonbreaking space in Ruby

Posted Over 13 years ago by Arne Hartherz.

Regular spaces and non-breaking spaces are hard to distinguish for a human. Instead of using the &nbsp; HTML entity...

Rails 3 Remote Links and Forms: A Definitive Guide

Posted Over 13 years ago by Lexy.
alfajango.com

Thanks to habits engrained by Rails 2’s link_to_remote and remote_form_for, we expect that Rails 3...

Request a non-HTML format in controller specs

Posted Over 13 years ago by Henning Koch.

If a controller action responds to other formats than HTML (XML, PDF, Excel, JSON, ...), you can reach that code in...

Get the current layout's name in a view or partial

Posted Over 13 years ago by Arne Hartherz.

This returns the name (including path) of your current layout: response.layout => "layouts/admin" # inside views that are using the 'admin' layout...

Use form_for without the enclosing form tag

Posted Over 13 years ago by Arne Hartherz.

In rare cases you might need something like form_for (for using form builder methods on the resulting block element...

Generate a path or URL string from an array of route components

Posted Over 13 years ago by Henning Koch.

When using form_for you can give the form's target URL either as a string or an array:

Match strings in a given order with Cucumber and Capybara

Posted Over 13 years ago by Dominik Schöler.

Sometimes the order in which strings appear on a page matters to you. Spreewald gives you steps like these:

Pay attention to the order of your submit buttons

Posted Over 13 years ago by Arne Hartherz.

If you have several submit elements (inputs or buttons with type="submit") that each cause different things to happen (e.g...

Places where cron jobs can hide

Posted Over 13 years ago by Henning Koch.

In /etc/crontab In /etc/cron.d/* In /etc/cron.hourly/* In /etc/cron.daily/* In /etc/cron.weekly/* In /etc/cron.monthly/* In the personal crontab of any user. This...

Use Sass without Rails

Posted Over 13 years ago by Henning Koch.

You don't need a Rails application to use Sass. Even when you're working on a static site you...

Define an array condition that selects on dynamic columns

Posted Over 13 years ago by Arne Hartherz.

For some reason you want to define a find condition in array form. And in that condition both column name...

Copying validation errors from one attribute to another

Posted Over 13 years ago by Henning Koch.

When using virtual attributes, the attached trait can be useful to automatically copy errors from one attribute to another.

Deliver Paperclip attachments to authorized users only

Posted Over 13 years ago by Henning Koch.

When Paperclip attachments should only be downloadable for selected users, there are three ways to go. The same applies to...

Create a valid RSS feed in Rails

Posted Over 13 years ago by Henning Koch.

This will show you how to create a RSS feed that the Feed Validator considers valid. Note that RSS is...