Fewer Rails Flash Messages

Dan Croak

Clearance 0.12.0 was released last week with a continued focus on user and developer experience.

For users: flashes

We removed redundant flash messages like ‘Signed in.’, ‘Signed out.’, and ‘You are now signed up.’ because it was visually obvious when you completed those actions.

We previously used flashes more to follow typical Rails convention (in controllers, successes get a flash and a redirect and failures get error messages and a render template) than providing informational value to the user.

For users: redirects

When a user reset their password, they used to get redirected to the sign in page with a flash message that said ‘You will receive an email within the next few minutes. It contains instructions for changing your password.’

We changed that to render a create.html.erb template with the same text because the sign in form is not what you want to see when you don’t know your password. We also wanted to make it clear that you have to leave the app to continue.

These changes became more obvious as we started to use sexy CSS3 flashes, which displays the flash for a few seconds, then hides itself without breaking a layout.

For developers: Rails version support via Appraisal

Clearance now works with Rails 3.0.x, 3.1.x, and 3.2.x. We use Appraisal to test against these versions of Rails:

['3.0.20', '3.1.11', '3.2.12'].each do |rails_version|
  appraise "#{rails_version}" do
    gem 'rails', rails_version
  end
end

For developers: no password necessary

We simplified the Cucumber features so developers don’t have to specify a password.

Previously:

Given I am signed up as "email@example.com/password"
When I sign in as "email@example.com/password"

Now:

Given I am signed up as "email@example.com"
When I sign in as "email@example.com"

We defaulted the factories so they always create users with password of “password”.

For developers: RSpec-compatible matcher

There’s a deny_access matcher. Since the earliest versions of Clearance, there was an “Shoulda macro”, which has fallen out of favor in place of matchers. This matcher only depends on Ruby and “should” work with any test framework like RSpec or Test::Unit.