View
External content

Test your CSS rendering output with GreenOnion

No one wants to cry over regression issues in views; does testing HTML and CSS have to be such a back and forth between designers and devs? Why is it that the rest of the stack can have TDD and BDD but not the presentation layer? Well, GreenOnion is here to help you get the same results on testing front-end styling that you've enjoyed in your unit and integration tests up to now.
GreenOnion records 'skins', which are snapshots of the current state of a view (or any page that a browser can navigate to). The first time that it is run on a view…

External content

jQuery 1.8 Released

No big features, but many improvements under the hood:

  • Faster selector engine
  • Many bug fixes

Note that jQuery 2.0, scheduled for early 2013, will remove support for IE6 and 7. Before that there will be one more minor release with 1.9 that still has support for ancient IEs.

rspec_candy 0.2.0 now comes with our most popular matchers

Our rspec_candy gem now gives you three matchers:

be_same_number_as

Tests if the given number is the "same" as the receiving number, regardless of whether you're comparing Fixnums (integers), Floats and BigDecimals:

100.should be_same_number_as(100.0)
50.4.should be_same_number_as(BigDecimal('50.4'))

Note that "same" means "same for your purposes". Internally the matcher compares normalized results of #to_s.

be_same_second_as

External content

MySQL 5.6 will expose tables as key/value stores through memcached, might be awesome

The next version of MySQL will include a built-in memcached daemon. This daemon can quickly get and set key/value pairs from and to InnoDB tables while completely bypassing the parsing and planning overhead of SQL.

This could potentially be very awesome because we would then have a distributed key/value store that stores data in a way it can also be queried with complex SQL queries.

Remove the module namespace of a qualified Ruby class name

You can use String#demodulize from ActiveSupport:

"ActiveRecord::CoreExtensions::String::Inflections".demodulize # => "Inflections"
"Inflections".demodulize                                       # => "Inflections"

Market share of web browsers

The usage shares of your site highly depends on your target audience. E.g. no Internet Explorer has ever seen hollyapp.com, but that's because of its tech-savvy audience. Distribution will also differ by other factors, such as region. See this Wikipedia article for details.

If you don't know your audience, you can use the stats of tracking tools, which see a lot of traffic go by a wide variety of sites. Some of these are:

  • [W3Counter](http://www.w3counter…

ReText

ReText is a cross-platform WYSIWYG-ish Markdown editor.

Toggle editor and preview layout with Ctrl+E.\
Press Ctrl+L to split the window for a live preview.

I use it to copy Pivotal Tracker story descriptions over, switch to the preview and have it as a small always-on-top window in a corner of one of my screens.


On Ubuntu, you can use a PPA to install:

sudo add-apt-repository ppa:mitya57/ppa
sudo apt-get update
sudo apt-get install retext
External content

Silencing Your Staging Environment - The Hashrocket Blog

Testing with real live production data does come with at least one catch. All those real live users in your production environment have real live email addresses that receive real live emails.

The post includes monkey patch for ActionMailer that rewrites the domain of all recipients. It's a different take on the problem than our own mail_magnet gem.

Don't follow Ajax requests with a redirect

The behaviour of browsers is very inconsistent when an Ajax request is answered with a redirect. Highlights are:

  • IE 9 will follow a DELETE request with a second DELETE. You never want that.
  • Firefox will follow a POST request with a GET, as you might expect. If a PUT is redirected however, you will get a confirmation dialog, where you can choose to follow with a second PUT or simply abort. You don't want that either.

See some workarounds here.

External content

Modifying Rake Tasks - Dan Manges's Blog

For custom Rake tasks, you shouldn't need to modify them after the original definition. However, if you want to add behavior to some vendor tasks (such as those defined with Rails), this blog post will cover how to do that.

Gem development: When your specs don't see dependencies from your Gemfile

When you develop a gem and you have a Gemfile in your project directory, you might be surprised that your gem dependencies aren't already required in your specs. Here is some info that should help you out:

  • Bundler actually doesn't automatically require anything. You need to call Bundler.require(:default, :your_custom_group1, ...) for that. The reason why you never had to write this line is that Rails does this for you when it boots the environment.
  • That also means that if you have an embedded Rails app in your spec folder (like [h…

Check if an object is an ActiveRecord scope

Don't say is_a?(ActiveRecord::NamedScope::Scope) because that is no longer true in Rails 3 and also doesn't match unscoped ActiveRecord classes themselves (which we consider scopes for all practical purposes).

A good way is to say this instead:

object.respond_to?(:scoped)
External content

Twitter Bootstrap: Base CSS

Explanation of the "bootstrap 2" base CSS.

Contains information about:

  • Typography
  • Code
  • Tables
  • Forms
  • Buttons
  • Icons

Fix error: Missing the mysql2 gem

So you got this error, even though your Gemfile bundles mysql2:

!!! Missing the mysql2 gem. Add it to your Gemfile: gem 'mysql2'

or

Please install the mysql adapter: `gem install activerecord-mysql-adapter` (mysql is not part of the bundle. Add it to Gemfile.)

The reason for this confusing error message is probably that your Gemfile says mysql2, but your database.yml still uses the mysql adapter. Change it to use the mysql2 adapter:

```raw
development:
adapter: mysql2
database: myproject_developm…

External content

RubyMine 4.5.1: Sass/SCSS Support Improvements

A number of issues concerning Sass/SCSS autocompletion and syntax highlighting were submitted as a feedback for RubyMine 4.5. Web development with Rails can’t do without Sass/SCSS code writing so we’ve decided to fix the most annoying bugs as soon as possible.

assignable_values 0.4.1 adds secondary default values

assignable_values now lets you define a secondary default that is only used if the primary default value is not assignable:

class Song < ActiveRecord::Base
  assignable_values_for :year, :default => 1999, :secondary_default => lambda { Date.today.year } do
    (Date.today.year - 2) .. Date.today.year
  end
end

If called in 2013 the code above will fall back to:

Song.new.year # => 2013

This is especially useful in authorization scenarios with [Consul](https://github….

Consul 0.4.0 released

Consul 0.4.0 comes with some new features.

Dependencies

  • Consul no longer requires assignable_values, it's optional for when you want to use the authorize_values_for macro.
  • Consul no longer uses ActiveSupport::Memoizable because that's deprecated in newer Railses. Consul now uses Memoizer for this.

Temporarily change the current power

When you set Power.current to a power in an RS…

Use the "paper_trail" gem to track versions of records

paper_trail is an excellent gem to track record versions and changes.

You almost never want to reimplement something like it yourself. If you need to log some extra information, you can add them on top.

It comes with a really good README file that holds lots of examples. I'll show you only some of its features here:

  • Setting up a model to track changes
    Just add has_paper_trail to it:
    class User < ActiveRecord::Base
    has_paper_trail
    end
  • Accessing a previous version
    Saying user.previous_version gi…
View
3150 cards