Testing state_machine callbacks without touching the database

Posted Over 13 years ago by Henning Koch.

You should test the callback methods and its correct invocation in two separate tests. Understand the ActiveRecord note before you...

The dangers of url_for in Rails applications

Posted Over 13 years ago by Lexy.
emphaticsolutions.com

In a great post about named routes in Rails, path vs. url, Viget Labs ponders which variant is best used...

wmd - The Wysiwym Markdown Editor

Posted Over 13 years ago by Lexy.
wmd-editor.com

WMD is a simple, lightweight HTML editor for blog comments, forum posts, and basic content management. You can add WMD...

When sessions, cookies and Clearance tokens expire and how to change it

Posted Over 13 years ago by Henning Koch.

Expiration of Rails sessions By default Rails sessions expire when the user closes her browser window. To change this edit...

Embed a favicon properly

Posted Over 13 years ago by Arne Hartherz.
w3.org

The following Haml will do: %head{ :profile => 'http://www.w3.org/2005/10/profile' } %link{ :href => image_path('favicon.ico'), :rel => 'icon', :type => 'image/vnd.microsoft.icon' }

Know your Haml comments

Posted Over 13 years ago by Arne Hartherz.

There are two distinct ways of commenting Haml markup: HTML and Ruby. HTML comments This will create an HTML comment...

Difference between respond_to/format and params[:format]

Posted Over 13 years ago by Thomas Eisenbarth.

To return non-HTML responses (like XLS spreadsheets), we usually use the respond_to do |format| format.xls do # send spreadsheet...

Bundler for Rails 2.3.x

Posted Over 13 years ago by Thomas Eisenbarth.

Update RubyGems and Passenger Bundler requires Rubygems >= 1.3.6. Run gem update --system if you have an older version.

Recursively remove unnecessary executable-flags

Posted Over 13 years ago by Arne Hartherz.

Sometimes files attain executable-flags that they do not need, e.g. when your Windows VM copies them over a Samba...

Unobtrusive jQuery to toggle visibility with selects and checkboxes

Posted Over 13 years ago by Tobias Kraze.

Use this if you want to show or hide part of a form if certain options are selected or boxes...

Regular Expressions - Cheat Sheet

Posted Over 13 years ago.
regular-expressions.info

You can write regular expressions some different ways, e.g. /regex/ and %r{regex}. For examples, look here. Remember that it...

Default implementation of resource_controller actions

Posted Over 13 years ago.
github.com

jamesgolick / resource_controller at Github module ResourceController module Actions def index load_collection before :index response_for :index end

Marry Capybara with SSL-enabled applications

Posted Over 13 years ago by Henning Koch.

Capybara does not play nice with sites that have some actions protected by SSL, some not. A popular way to...

rspec_candy is now a gem

Posted Almost 12 years ago by Henning Koch.
github.com

Our awesome collection of rspec helpers (formerly known as "spec_candy.rb") is now available as a gem. It works, it is...

Get TinyMCE editor content as HTML

Posted Over 13 years ago by Tobias Kraze.

tinyMCE.activeEditor.getContent()

Submit a form with Prototype

Posted Over 13 years ago by Tobias Kraze.
prototypejs.org

For example, to send a form and populate a preview div with the response. $('content_form').request({ parameters: { 'preview': "1...

Autofocus a form field with HTML5 or jQuery

Posted Over 13 years ago.

In Webkit you can use the HTML5-attribute autofocus: = form.text_field :title, :autofocus => 'autofocus' Here is a jQuery fallback for...

Cucumber Webrat steps

Posted Over 13 years ago by Lexy.

Most of these will not work in newer projects because these use the Capybara/Rack::Test combo in lieu of Webrat...

Release gem; Deploy gem; Update a gem created with Jeweler

Posted Over 13 years ago by Henning Koch.

Until May 2011 our gems have been created with Jeweler, which is a helper library to package code into a...

Aggregated RSpec/Cucumber test coverage with RCov

Posted Over 13 years ago.

With defaults, RCov doesn't work the way you how you would like it to. To create a nice test...

Parse XML or HTML with Nokogiri

Posted Over 13 years ago by Tobias Kraze.

To parse XML-documents, I recommend the gem nokogiri. A few hints: xml = Nokogiri::XML(" foo bar ") parses an xml...

Automatically build sprites with Lemonade

Posted Over 13 years ago by Tobias Kraze.

See the lemonade descriptions. Unfortunately, the gem has a few problems: it does not work with Sass2...

Convert Haml to ERB

Posted Over 13 years ago by Henning Koch.

This is about converting Haml to ERB and not the other way round which you probably want! This process can...

Typical .gitignore

Posted Over 13 years ago.

tmp/* storage/* db/*.sqlite3 db/schema.rb db/structure.sql public/system .project .idea/ public/javascripts/all* public/stylesheets/all* public/stylesheets/*.css config/database.yml *~ *#* .#* .DS_Store webrat-*.html