Double Shot #823

Today I ship my last Windows server off to a good home.

  • Amazon Simple Workflow - Workflow management in the cloud, of course tied in to all the other Amazon web services.
  • atea - Open source menu bar time tracker for OS X that maintains state in text files.
  • Curator - Model/repository framework from Braintree that separates persistence from domain logic. At the moment your choice for persistence is Riak, but that should expand if it catches on. See the announcement blog post for more info.
  • Nezumi - Remote management for Heroku apps on iOS or Android.
  • Maqetta - Browser-based IDE for HTML5 user interfaces.
  • I Told You it Was Private - Actively punish code that calls your private interfaces.
  • RABL - General purpose templating system for APIs, that can generate JSON, XML, MessagePack, PList, or BSON files.

Using CarrierWave and S3 with Mercury Editor

I've been using Mercury Editor in a new project to get editable text directly in the browser. By default, it stores images locally, but we wanted to put them on Amazon S3 instead. Here's what that took using CarrierWave:

Add a model to hold the images


class BlogImage < ActiveRecord::Base
  mount_uploader :image, ImageUploader
end

Not much to see here, just a single string attribute to hold the image info.

Add an uploader


require 'carrierwave/processing/mime_types'
class ImageUploader < CarrierWave::Uploader::Base
  include CarrierWave::RMagick
  include CarrierWave::MimeTypes
  process :set_content_type
  storage :fog
  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end
end

Obviously you could process extra versions or limit extensions here, but all Mercury needs is someplace to dump what it takes in.

Replace the Mercury Images Controller

To hook everything up, you just need to replace the images controller in the engine with app/controllers/mercury/images_controller.rb in your project:


class Mercury::ImagesController < MercuryController

  respond_to :json

  def create
     @blog_image = BlogImage.new(params[:image])
     @blog_image.save!
     render :json => @blog_image.to_json(:only => :image)
  end

  def destroy
    @image = BlogImage.find(params[:id])
    @image.destroy
    respond_with @image
  end

end

Double Shot #822

It remains The Year Without Winter here, and I can't say I object.

What's New in Edge Rails #9

Week of February 12-February 18, 2012

Things are still moving along in the usual Rails fashion of incremental improvement.

  • There was a bunch of work on the internals of inflections, including d3071db1 which, if I'm reading it right, is a serious bit of optimization.
  • d6b26a6 adds date_field and date_field_tag helpers to create HTML5 date inputs.
  • 951b5820 makes it easy to run a class other that IRB as your Rails console - a boon for Pry users.

Double Shot #821

Some links from the part of the weekend that I didn't spend out in the woods.

Double Shot #820

Double Shot #819

Isn't it Friday yet?

Double Shot #818

Time to get on with the day.

Double Shot #817

Snow on the ground for the first time this winter. Doesn't look like it'll last long though.

What's New in Edge Rails #8

Week of February 5-February 11, 2012

Some goodies for PostgreSQL users this week, as well as other odds and ends.

  • As of d70e0236 Active Record supports PostgreSQL partial indexes. add_index(:accounts, :code, :where => "active") generates CREATE INDEX index_accounts_on_code ON accounts(code) WHERE active.
  • f7b915b5 adds support for PostgreSQL hstore columns.
  • Working with CoffeeScript gets just a tiny bit nicer now that rake notes picks up annotations from .coffee files in dd8c6f05.
  • I'm not convinced of its utility, but 60dad828 allows you to provide Float::INFINITY as an argument to validates_length_of.
  • A batch of commits replaced use of ActiveSupport::OrderedHash with pure Ruby 1.9 hashes.

Double Shot #816

Flotsam and jetsam from my weekend.

Open Source Report #5

Looking for a way to get involved with open source? How about the Ruby Documentation Project? They've got a list of areas in Ruby that need help and a step-by-step guide for helping out. And how cool would it be to have your work committed to core Ruby?

As for myself, it's been a slow week, but I've been moving along:

  • RubyGems Guides - Most of my open source work over the past week went here. I've now finished an editing pass over the whole thing, and added new material to the credits, resources, and FAQ pages. Next up: porting over what's still worth preserving from the old RubyGems Manuals site. Details are in the repo.
  • Tabulous - I had to put together a patch to make this tabbed navigation library play well with Bootstrap 2.0 for a client. As it happens the lead developer worked up his own patch at the same time, so I won't be submitting mine upstream.
  • axlsx - I've been needing this Office Open XML generator in a Rails 3.0 project, which required meddling with the gemspec. It seems to be working fine, so I'll be sending that tiny change back upstream.
  • And of course there was the new What's New in Edge Rails.

Double Shot #814

Double Shot #813

The New York Times has discovered multiple monitors. I'm amused.

Double Shot #812

Winter appears to finally be visiting for a few days.

What's New in Edge Rails #7

Week of January 29-February 4, 2012

Things are still moving along on the Rails 4 front, with a mix of tidying up and new features. Here are some of the commits that caught my eye last week.

  • A whole mess of commits worked over some of the collection form helpers. Now collection_select and options_from_collection_for_select can take procs to evaluate their text and value in the current context, and there are new collection_check_boxes and collection_radio_buttons helpers. The easiest starting point is with f506c806 which documents the API changes.
  • 8270e4a8 implements the null object pattern for Active Record relations. Post.none will return a relation containing no posts - which may seem daffy, but makes for much nicer chainable methods on your Active Record objects.
  • b31eac56 replaces all for loops in the Rails source code with Enumerable#each. This should lead to considerably less confusion for new Rails developers.
  • 336ff8a9 reworks the :dependent => :restrict construct for Active Record associations to deprecate raising an exception on violation.
  • 66c04431 updates Rails' Unicode support from 6.0 to 6.1, making it pile of poo compatible.

Double Shot #811

Not so much to report this morning, since I spent a good chunk of the weekend out with the Boy Scouts.

Open Source Report #4

In the spirit of keeping myself honest, here's what I've touched on open source work over the past week. Most of it isn't spectacular, but I did manage to do something every day in January and I'm happy about that.

Double Shot #810

A few orts to close out the work week.

subscribe via RSS