Synthesis

Asset Packager – Rails 3 / Ruby 1.9 Compatible

Hello! Here is a long overdue update to Asset Packager, which now makes the main branch Rails 3 and Ruby 1.9 compatible. Thanks to all those on Github who sent me patches with these fixes.

Updates

  • Fix thread safety issue.
  • JSMin compatibility fix for Ruby 1.9.1 – Fixnum#ord
  • Rails >= 2.3 test compatibility
  • Rails 3 deprecations – change RAILS_ROOT to Rails.root, change RAILS_ENV to Rails.env, move tasks to lib dir

All About Sammy

Got another quick presentation for ya. I discovered Sammy yesterday. I gave a quick talk about it today. That’s how easy it is to understand!

Sammy is a tiny, client-side JavaScript framework, created by the obviously brilliant Aaron Quint, built on jQuery, and inspired by the server-side Ruby framework Sinatra. It’s the minimalist’s framework for RIAs. You know, those uber rich internet applications. Single page, no refresh apps. Like Gmail. Except without all those kilobytes you may or may not ever need. Sammy is 7kb, minified. And gzipped? You won’t even know you downloaded it.

Watch the preso for more…

If you want to learn more about Sammy, check out Aaron’s blog post which has a nice introduction and screencast.

Agile JavaScript Testing

A couple weeks ago, I gave a talk at the Open Source Bridge conference in Portland Oregon on Agile JavaScript Testing.

In this presentation, I first gave an overview of Test Driven Development for those front-end JS developers who might not have heard of it yet (!) and then the difference of TDD vs. Behavior Driven Development.

I then walked through some tools:

  • Screw.Unit, a nice BDD framework for JS that is quite similar to RSpec in Ruby land.
  • Blue Ridge, a plugin for rails that integrates Screw-Unit with Rhino and Env.js and some rake tasks to create a command-line driven headless (no-browser == fast) testing workflow.
  • JS Test Driver, a project that mounts one or more browsers as slaves, and a command-line tool which notifies all the listening browsers to run tests and aggregates the results. Very cool!

In the actual presentation I even did some live coding examples of Blue Ridge and JS Test Driver, and they worked perfectly. Here are the slides from the talk:

SproutCore Slides

Here are the slides for the presentation I gave the other week at the Portland JavaScript Admirers meeting: SproutCore – A Next Generation JavaScript Framework. It is an overview of some of the key features I think make SproutCore unique and very useful. There was also video recorded which should hopefully appear online soon. I plan to do another SproutCore focused talk with a walkthrough of a full backend-connected application.

Starting Fresh, Without the Big Rewrite

If you’re working on a project with a couple years of code under it’s belt, you may have moments of desire to completely throw the whole thing out and start anew. But, if you’re working for someone else, you know that your boss or client probably won’t like that. After all, he’s paying you to finish feature A! But, you lament, feature A builds on top of feature B that already exists but is written in a terribly unidiomatic, pre-TDD, pre-REST way, way before you or someone else learned the dark arts of coding mastery. Legacy code, argh!

So what should you do? What are your options? A) Ignore the problem and build the new feature on top of the existing badly written code. Watch things get even worse. B) Try to quickly fix the badly written code in-place so you can get on with it. Trigger cascading test failures, and palm your face. C) Start over and rewrite the entire project, get fired for being 6 months late on your estimate. None of these sound any good!

I think I may have found a solution that works for me, especially with Rails.

Start a fresh Rails project. Boom! It’s fresh and clean. Now you have room to work. The beauty of Rails is how quick it is to get started. Choose the aspect of the project you want to work on. Got some legacy code thats bugging you? TDD/BDD it from scratch, the Right Way. The idiomatic, Rails Way. Once you get it to the point where it’s working correctly and passing all tests, you can merge the new code into the main project, replacing the older, ugly, what-were-they-thinking legacy code that was getting in the way.

Now you can work in a clean environment and just focus on the problem at hand. This allows you to make progress quickly, and get rid of the old crap without having to completely start from scratch.

AssetPackager update

A long overdue update of AssetPackager is finally here:

  • Rails 2.2 compatibility fixes
  • Packages generated on demand in production mode. Running the asset:packager:build_all rake task no longer necessary.
  • Now compatible with Git, and any other revision control system since revision numbers are no longer used.
  • No more mucking with internal Rails functions, which means:
    • Return to use of query-string timestamps. Greatly simplifies things.
    • Multiple asset-hosts supported
    • Filenames with ”.”’s in them, such as “jquery-x.x.x” are supported.

Get the latest at http://github.com/sbecker/asset_packager

Thanks to the many forkers for ideas and solutions.

AssetPackager Tracker

Asset Packager now has a tracker where you can submit tickets. You can find it here.

If you have a bug to report, and/or a patch for Asset Packager, this is the place.

WeoGeo – AWS Startup Challenge Finalist

My company WeoGeo made it to the final round of the Amazon Web Services Startup Challenge. In the top 7 out of around 1000 entrants, not too shabby.

Check out the videos for the finalists, and vote for WeoGeo!

RubyBrigade.org – A Rails Rumble Success

Just wanted to mention our Rails Rumble project, RubyBrigade.org. Jason Perry, James Seaman and I
worked through the weekend to build RubyBrigade.org – a geographically aware database of Ruby User groups.

Big thanks to James for the killer hand drawn illustrations and interface. Big thanks to Jason & Katie for letting us take over their house for the weekend.

Features:

  • Google Maps Integration
  • Sub-domains for each group
  • Geocoding: either by the search box or by sub-domain!
  • RSS and iCal feed parsing
  • Display latest user groups
  • Display upcoming events across all groups
  • Display blog posts & upcoming events for individual groups
  • ReCAPTCHA for spam prevention
  • No authentication required

More Screenshots

View a Brigade

Edit a Brigade

Delete a Brigade

404 Message

If you like what you see, vote for us!

Are you SURE?! (How to confirm HTTP methods in Rails)

In Scott Raymond’s excellent book Ajax on Rails I came across a cool (non-ajax related) pattern for insuring a request’s method is POST and showing a confirmation form if not.

This is really useful in situations such as confirmation links in emails, where a form can’t be displayed and javascript won’t work, yet we don’t want a destructive action occurring through a GET request.

Here’s an example:

def unsubscribe
  if request.post?
    @user = User.find(params[:id])
    @user.update_attributes :subscribed => false
    redirect_to home_url
  else
    render :inline => %Q(
      <% form_tag do %>
        <%= submit_tag 'Confirm' %>
      <% end %>
    )
  end
end

One other piece of code you’ll need to get this to work, assumming you’re using RESTful routes, in config/routes.rb

map.resources :users, :member => {:subscribe => :any, :unsubscribe => :any} 

This states that we have a couple extra actions in our controller, and we’re not going to mandate a specific HTTP method to get there. This way we can handle it within the action if the HTTP method is wrong.

Now if your user comes to your page from a straight GET request, he’ll get prompted to confirm the big destructive action he’s about to commit.

(In a real app we’d make this form look a bit nicer.)

Wouldn’t it be nice if we could re-use this pattern, without writing out the inline form code every time? Seems generic enough.

DRY it up!

We could abstract that out, and also support any HTTP method we want. Lets follow Rails / RESTful conventions , and require PUT for updating a model. Using some handy ruby block syntax, we could write something like, say:

def unsubscribe
  confirm_unless :put do
    @user = User.find(params[:id])
    @user.update_attribute :subscribed, false
    flash[:notice] = "User is now unsubscribed"
    redirect_to users_url
  end
end

Much better. But how?! Keep reading.

Get one for yourself!

To get the confirm_unless method for yourself, slap the following code into app/controllers/application.rb:

def confirm_unless(method)
  if request.method == method
    yield
  else
    render :inline => %Q(
      <% form_tag({}, :method => :#{method}) do %>
        <%= submit_tag "Confirm" %>
      <% end %>
    )
  end
end

We could take it one step further and make it a before_filter, but I’ll leave that for a possible future post.

Archives

buy paxil
buy norvasc cheap
buy line viagra
generic viagra quality
Buy levitra San Francisco
Buy cialis Tacoma
buy generic viagra usa
viagra 10 generic
Buy cialis Detroit
Buy levitra Milwaukee
buy viagra safeway pharmacy
buy viagra from canada
generic viagra work
buy rolex watch replica
buy generic cialis softtabs online
ophthalmic cipro
generic viagra viagrageneric
buy viagra fedex
buy n viagra
cheap generic nolvadex order
generic viagra usa
buy generic propecia online
buy cheap levitra online
buy generic levitra online
Buy viagra Richmond
buy zantac
buy cialis re
buy viagra cleveland
buy cheap nexium emedoutlet
buy viagra online australia
buy lasix nextday
buy cheap online soma
Buy viagra Indianapolis
Buy levitra Tacoma
Buy viagra Arlington
cheap viagra for men
cheapest zocor
purchase tamiflu
buy generic viagra img
buy line soma
buy lexapro
buy cailis viagra singapore
cheapest paxil
Buy levitra Kansas City
Buy viagra Tulsa
buy cheap nexium india
generic viagra for sale
buy viagra ups
buy cheap effexor xr
Buy viagra Baltimore
german viagra substitutes
buy line propecia
buy nolvadex online
Buy cialis Newark
bye viagra
online viagra prescription canada
Buy cialis Mesa
buy cheap evista generic
buspar online
buy zocor
buy corum
buy linecom soma
buy viagra onlines
cheap canadian cialis online
Buy levitra Austin
Buy cialis Portland
buy cialis today
buy men watch
Buy viagra Fort Worth
generic viagra doxycycline
cheap cialis for sale
buy cheap generic ultram
generic viagra purchase
buy viagra pills
generic viagra with money order
generic viagra uk
Buy cialis Oxnard
dd3 memory
ordering viagra online
buy neurontin
online uk viagra
Buy cialis Fresno
buy viagra online paypal
generic viagra wholesale
buy generic zocor
buy synthroid
Buy viagra Seattle
buy mont blanc pen
buy multi vitamins
buy viagra in australia
buy viagra professional
online viagra testosterone
buy carisoprodol generic soma
buy crestor
Buy levitra Seattle
Buy viagra Louisville
cheap altace buy online
cheap generic norvasc online
online viagra with insurance
Buy viagra Long Beach
Buy cialis Atlanta
buy lasix fast
online perscriptions for viagra
online viagra uk
buy cialis soft
Buy viagra Oakland
buy cheap generic viagra
Buy cialis Pittsburgh
buy viagra discrete uk
buy nolvadex mexico
generic viagra without visa
buy canada in propecia
generic viagra cheap no prescription
Buy viagra Fresno
Buy viagra Denver
online viagra consultation
Buy levitra Philadelphia
buy viagra in england
buy viagra iframe src
Buy cialis Indianapolis
generic viagra drugstore india
buy prilosec
online pharmacy viagra no prescription
generic in uk viagra
buy cialis uk
buy viagra pharmacy online
Buy viagra Buffalo
online viagra sale
Buy cialis Albuquerque
buy panerai watches
online viagra canada
buy viagra and overseas
generic viagra caverta
buy viagra inte
buy buy prilosec online
Buy cialis Columbus
buy men watches
generic viagra year
buy prevacid
buy levitra
Buy cialis Riverside
buy nexium where
online viagra pharmacie miami florida
cheap discount india viagra
buy tamiflu
Buy cialis Omaha
buy viagra online discount
Buy viagra Portland
buy viagra prescription online
online prescription prilosec viagra
Buy levitra Phoenix
buy viagra for cheap
purchase ultram
Buy viagra Tacoma
buy generic lipitor online
generic viagra cialis
buy viagra discrete england
generic viagra caverta cialis cheap
buy cialis softtabs
buy viagra in amsterdam
buy viagra with paypal
online ordering viagra
buy cialis viagra
cheapest zithromax
buy kamagra
cialis
buy generic nexium online
Buy viagra Houston
buy viagra online au
Buy levitra Baltimore
generic viagra tab
Buy cialis Minneapolis
buy cheap buspar
buy norvasc 5mg
buy viagra from safeway
online viagra for sale
Buy viagra San Francisco
Buy cialis Memphis
buy nolvadex liquid
buy viagra order viagra
phisher viagra
buy viagra texas
buy zyrtec
cheap viagra cialis india
Buy levitra Oxnard
generic viagra fast delivery
buy neurontin prescription
buy cheap generic prilosec
cheapest pravachol
buy viagra per pill
buy viagra internet
online pill viagra
online order viagra viagra
generic viagra rd
buy swiss watch
generic viagra canada
buy flomax
Buy cialis Buffalo
buy levitra onlines
buy viagra usa
online prescription viagra without
buy viagra for women
buy somas
generic viagra cheap
generic viagra cialis pills
buy generic xenical
cheapest viagra
cheap allegra without prescription
msi barebones
online zyrtec
buy replica watches
Buy levitra Albuquerque
purchasing viagra online for cheap
onlinenmru ultram
Buy levitra Riverside
generic viagra drugs brand order pill
buy imitrex
buy panerai watch
msi k7n2 delta 2
generic viagra woman
buy tenormin
Buy cialis Long Beach
Buy viagra New Orleans
cheap altace online cheap
cheap celebrex
Buy levitra Tulsa
buy cheap evista online
cheapest xenical
buy cheap diflucan online
Buy levitra Minneapolis
generic viagra today atlanta
Buy levitra Pittsburgh
buy keyword viagra
online prescription soma viagra zoloft
online viagra prescription
Buy viagra San Antonio
buy cialis toronto
Buy cialis Louisville
cheap evista online cheap
buy cheap online xenical
buy viagra los angeles
buy viagra uk
buy viagra online buy
buy viagra phuket
buy from pharmacy us viagra
buy canada online zyban
Buy viagra Nashville
cheap drugs viagra cialas
cheapest prilosec
generic viagra cheapest substitute
Buy levitra Charlotte
Buy levitra Indianapolis
buy corum watches
buy replica wrist watches online
generic viagra caverta veega generic viagra
purchasing viagra in mexico
Buy viagra Phoenix
purchase xenical
buy viagra by pill
buy viagra online india
buy viagra pill
Buy levitra Detroit
phizer viagra
online sale viagra
online us pharmacies generic viagra softtabs
generic indian viagra
buy cheap kamagra uk
online ritalin viagra paypal
Buy levitra Tucson
cheap atarax no prescription
Buy cialis Fort Worth
buy diflucan
generic viagra pricing
buy zyprexa
buy rolex replica
Buy viagra Las Vegas
buy generic zithromax
buy viagra at safeway
buy levitra viagra
buy viagra in london
buy plavix
cheap generic overnight viagra
buy viagra pill online
buy xenical
buy generic viagra pharmacy online
buy nexium online
buy cialis tadalafil
Buy viagra Memphis
Buy cialis San Francisco
viagra 100
buy glucophage
buy mens watch
cheap generic viagra deals
buy viagra in boston
generic viagra with american express
online viagra overnight
Buy viagra Minneapolis
buy cheap generic propecia
buy ultram
Buy viagra Detroit
online viagra levitra cialis
online viagra viagra
buy generic allegra d
buy cheap generic cialis
Buy cialis Las Vegas
Buy levitra Portland
generic viagra discount
generic in usa viagra
online prescriber of viagra
Buy viagra Tucson
Buy levitra Fresno
Buy levitra Denver
cheap est xenical online
cheapest propecia
Buy levitra New Orleans
Buy levitra Omaha
cheapest premarin
discount buspar
online viagra cialis ricetta
cheap claritin d 12hr
generic viagra cheapest
Buy cialis Rome
online prescription ultram viagra
cheapest singulair
buy generic href info levitra
Buy viagra Philadelphia
Buy viagra Columbus
buy viagra online online
Buy levitra San Antonio
cheapest silagra
generic viagra capsules
buy viagra in spain
buy generic tramadol no prescription
buy singulair
Buy cialis Denver
generic viagra us licensed online pharmacy
buy nexium
online viagra store
Buy cialis Phoenix
buy viagra soft tabs
cheap free shipping soma
generic viagra uk online pharmacy
buy caverta
buy generic singulair
cheap generic cialis tadalafil
buy propecia for less
buy viagra canada review
buy generic online zyrtec
buy viagra in chicago
cheap cipro
buy viagra new york
Buy cialis San Antonio
Buy levitra Buffalo
buy viagra online order
purchase and viagra soft
cheap allegra online pharmacy
buy now cialis
buy depakote
online sales viagra
buy viagra viagra online
free christmas ringtones
buy claritin
cheap evista buy online
buy viagra in canada
buy generic cialis uk
Buy cialis Charlotte
generic viagra trial pack
Buy levitra Newark
cheapest protonix
generic viagra viagra
buy viagra no prescription
online viagra prescriptions
cheap viagra fast shipping
Buy levitra Fort Worth
buy viagra in malaysia
Buy viagra El Paso
purchase zyban
Buy viagra Rome
generic viagra cheapest online
Buy viagra Austin
cheap generic drugs caverta
buy cheap online viagra
buy cheap generic zyban
phiser viagra
Buy levitra Richmond
buy viagra sale
buy norvasc usa
buy generic levitra cheap
ddr2 memory
online parm viagra
buy viagra from britain
buy cialis where
cheap altace no prescription
Buy levitra El Paso
buy viagra san jose
cheap evista generic order
Buy cialis Nashville
buy viagra cialis levitra
buy viagra using paypal
cheap generic india viagra
buy viagra toronto
buy coumadin
buy montblanc
buy avandia
buy viagra low cost
buy generic online prilosec
generic form of viagra
cheap cialis