How to grep through the DOM using the Capybara API

Posted Almost 13 years ago by Henning Koch.

When your Cucumber feature needs to browse the page HTML, and you are not sure how to express your query...

How to diff two strings in Ruby

Posted Almost 13 years ago by Dominik Schöler.
github.com

When you need to use diff in either some Ruby code or your Rails app, use the differ gem.

JSONP - Wikipedia

Posted Almost 13 years ago by Lexy.
en.wikipedia.org

Under the same origin policy, a web page served from server1.example.com cannot normally connect to or communicate with a server...

Use Capybara on any HTML fragment or page

Posted Almost 13 years ago by Lexy.
robots.thoughtbot.com

I think this pattern is really useful not just for upgrading suites from Webrat, but really anywhere you have an...

simple_format helper for Javascript

Posted Almost 13 years ago by Henning Koch.

The Javascript code below is a rough equivalent to the simple_format helper that ships with Rails: function simpleFormat(str...

A few hints when upgrading to Ruby 1.9

Posted Almost 13 years ago by Tobias Kraze.

Note: If you are currently working with Ruby 1.8.7 or 1.9.3, we recommend to upgrade to Ruby 2.1 first. From...

Rails 3: Make "link_to :remote => true" replace HTML elements with jQuery

Posted Almost 13 years ago by Tobias Kraze.

In Rails 2, you could use link_to_remote...

...:update => 'id' to automatically replace the content of $('#id').

Virtual attributes for date fields

Posted Almost 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...

Shell script to generate a Git commit with Pivotal Tracker story ID and title

Posted Almost 13 years ago by Tobias Kraze.

We usually generate our commit messages from Pivotal Tracker IDs and titles, like [#15775609] Index view for conflicts

Configuring ActionMailer host and protocol for URL generation

Posted Almost 13 years ago by Henning Koch.

When you generate a URL in a mailer view, ActionMailer will raise an error unless you previously configured it which...

Popular mistakes when using nested forms

Posted Almost 13 years ago by Henning Koch.

Here are some popular mistakes when using nested forms: You are using fields_for instead of form.fields_for.

How to build the perfect number of blank records for a nested form

Posted Almost 13 years ago by Henning Koch.

When you render a nested form for a Movie which has_many :actors, you want to render the right number...

How to use helper methods inside a model

Posted Almost 13 years ago by Tobias Kraze.

If you want to use a helper_method my_helper_method inside a model, you can write ApplicationController.helpers.my_helper...

Helpers to render (money) amounts

Posted Almost 13 years ago by Henning Koch.

When rendering a number, you want to pretty up the string coming from #to_s: Render 0.0 as 0

Soft-scroll to an anchor with jQuery

Posted Almost 13 years ago by Arne Hartherz.

This snippet makes links that refer to an anchor (like "...

...") scroll softly to it.\ In this example we only do...

Semantic markup standard for search engines

Posted Almost 13 years ago by Ulrich Berkmueller.
schema.org

If you would like to enrich your website with semantic markup like contact data, places or events you should have...

Matching elements on complex web pages with Webrat

Posted Almost 13 years ago by Lexy.
devblog.imedo.de

XPath matchers can be combined with CSS-selector matchers. This is really useful if not, for example, the content of...

Using StaticMatic for static pages

Posted Almost 13 years ago by Tobias Kraze.

Update: Staticmatic will not be further developed. They suggest to switch to middleman. If you need to make a static...

Center a float horizontally

Posted Almost 13 years ago by Tobias Kraze.

Note: We have card with all CSS centering options. You probably want to head over there and get an overview...

How to define helper methods in magic DSL code

Posted Almost 13 years ago by Lexy.
gem-session.com

We use the lambda-technique to DRY up our Rails routes machinist blueprints, and, of course, RSpec examples.

Conditional comments for Internet Explorer with Haml

Posted Almost 13 years ago by Henning Koch.

Internet Explorer 5+ is aware of conditional comments that let you target HTML for selected versions of IE. For example...

Playing audio in a browser

Posted About 13 years ago by Henning Koch.

If you want to play music or sounds from a browser, your choice is to use either Flash or the...

Haml and Sass 3.1 are Released

Posted About 13 years ago by Lexy.
nex-3.com

Sass now comes with user-defined functions, keyword arguments, list manipulation. Haml and Sass are now two separate gems.

How to fix strangely disappearing or misbehaving forms

Posted About 13 years ago by Arne Hartherz.

You most likely have a form element inside another form element. Don't do that. Ever. Firefox and Chrome will...