Currently working on: Learning WebGL
Gems I like right now
acts_as_votable my 2.x fork
old school flavor
Capybara, you still suck
Granted, you’re faster now that I can target Chrome. But you still ruin my day when I spend half of it getting the selectors right in the tests to fill out a form, and you stop everything with the submit button error:
(::) failed steps (::)
Element is not clickable at point (359, 861)
Interestingly, a spinner widget I used for Ajax loads was the culprit. It created a canvas to draw itself on, and for whatever reason it was considered as having obscured pretty much the whole form.
So maybe Capybara doesn’t suck as much as I thought it did..
Rails 2->3 Upgrade Part 3
Coming back to this after so many months!
- Sprockets integration is awesome - I can finally start writing my JS in CoffeeScript! Hopefully convert some of the existing JS too when I get the time.
Probably a good time to start learning SASS too…
- form_for: ugh gotta add an
<%=to all those views now.
- form_for_remote, link_to_remote: double-ugh. Do I really have to UJS everything?
- auto_link is gone, using Rinku now
gem 'rinku', :require => 'rails_rinku'
- cells state methods must be now explicitly accept an opts argument bah.
- routes Lots of typing needed if you have a lot of custom routes like me.
class_inheritable_accessor => class_attribute
Ok some I’m a little late to the Rails 3 party…but this is for those people stuck maintaining large Rails 2 codebases and slowly trying to upgrade.
Anyways the class_inheritable_accessor and class_inheritable_array hack has now been improved. Use class_attribute instead. Source here
Middleman + Backbone.js
Last time I posted about the awesome Middleman app (See “Middleman & Coffeescript”) (how do I link to my posts??), I extolled the wonders of its CoffeeScript integration.
Since I have been deep diving into Backbone.js for a client admin-type project (has YAAI been used for Yet Another Admin Interface?), I found that I could still use Middleman for all the wonderful dynamic development while keeping the Backbone app/ layout intact within source/.
Even better, I can use CoffeeScript to write Backbone.js code.
This means you CRUD your model data using Ajax calls from within Backbone.
Of course, the API scripts should’nt have to live on the same dev domain as Middleman, which is typically localhost:4567 anyways. So in order to prevent Ajax calls from breaking due to XSS same-host policy, we must use a Proxy.
Simply setup proxy calls in Middleman’s config.rb and all your Backbone ajax calls will work flawlessly.
My current config looks like this:
require 'middleman-proxy' activate :proxy proxy '/api', :to => "my-api-server.local:80"
CoffeeScript => Closure!!
Squee! Free CoffeeScript to JS that can be compiled using Closure compiler’s Advanced mode! hottt