How to grep through the DOM using the Capybara API
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
When you need to use diff in either some Ruby code or your Rails app, use the differ gem.
JSONP - Wikipedia
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
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
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
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
In Rails 2, you could use link_to_remote...
...:update => 'id' to automatically replace the content of $('#id').
Virtual attributes for date fields
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
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
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
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
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
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
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
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
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
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
Update: Staticmatic will not be further developed. They suggest to switch to middleman. If you need to make a static...
Center a float horizontally
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
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
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
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
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
You most likely have a form element inside another form element. Don't do that. Ever. Firefox and Chrome will...