Double Shot #512

Lots of people are excited about Rails and 37Signals being mentioned in Microsoft’s annual Form 10-K. I think that’s just silly. This isn’t any sort of acknowledgement that Microsoft considers us a serious threat; it’s a “cover your ass” survey of software and firms whose business overlaps that of Microsoft. For some perspective, go look at other 10-K’s; for example, the one for McDonald’s says “The Company’s competition in the broadest perspective includes restaurants, quick-service eating establishments, pizza parlors, coffee shops, street vendors, convenience food stores, delicatessens and supermarkets.” So, yeah – McDonald’s:street vendor::Microsoft:37 Signals. That’d be about right.

  • NoSQL: If Only It Was That Easy – Look at some of the currently-sexy database alternatives by someone who actually evaluated at heavy load.
  • Deployment Script Spring Cleaning – New ideas on using Capistrano with git, from the GitHub guys.
  • Napkee – Convert Balsamiq Mockups to HTML/CSS/JSS/Flex 3 source.
  • Lone Star Ruby Conference – One more week for registration for this Texas conference at the end of the month.
  • Cerberus 0.7 – Lightweight continuous integration, now with Bazaar support and better Git support.
  • RailsBridge BugMash – Contribute to the Rails core – Just a reminder: it’s coming up this weekend.
  • complex-form-examples – Ryan Bates takes a shot at showing ways to manage forms with nested attributes.
  • va_cache – Simple caching for Active Record virtual attributes.
  • Double Shot #498

    Early morning with small child and thunderstorms.

    Double Shot #497

    Up late deploying stuff last night, so just a couple of quick links this morning.

    • snail – Start of an ambitious attempt to build a plugin to format international mailing addresses.
    • Firebug 1.4.0 – Officially released, and nicer than 1.3. Of course those of us on the bleeding edge have moved to 1.5 alpha builds already.

    Double Shot #496

    It looks like the Fairy Godmother Department’s lunch hour may be over.

    • Many Ways to Tag Taggables – Tobias hunted down all the Rails tagging libraries he could find. Looks like he settled on acts_as_taggable_on, which is the one I use too.
    • fleakr – Flickr API integration gem recommended by a couple of my readers.
    • read_from_slave – Read your Rails data from a MySQL slave database, while ensuring that writes go to the master database.
    • Programming Contest! Win iPhone 3GS & $2,000 Cloud Credit – Engine Yard is planning a contest that is going to make Twitter even more annoying for a while.
    • Choosy – OS X utility ($12) to let you choose a browser when you click on a link.
    • Ruby Versions – SSH access to a bunch of new and archived flavors of Ruby.

    Double Shot #495

    Time to get back on the daily sales and marketing wagon. Contract, where are you?

    • Build Guild – Spreading social/technical gathering of web folks. I’d be tempted to start an Evansville/Newburgh chapter if I actually knew any other web folks around here.
    • wikicloth – Mediawiki markup for Ruby.
    • flickr_fu – I may need a flickr interface in Ruby soon. This one looks promising.

    Double Shot #494

    Lots of interesting new stuff showed up over the weekend:

    • i18n – The i18n gem has reached version 0.2.0 with lambda support among other goodies.
    • can_touch_this – A permissions system extracted from rboard.
    • sort_by – Active Record/ Action View extension to produce user-sorted, paginated tables in your views.
    • Posterous now supports TrailerAddict embeds and Github Gist code drops. – With Gist support, Posterous is getting to be an interesting alternative for a quick & dirty coding blog.
    • Installing FreeImage and ImageScience on Debian Linux – Came in handy, though note that the current version of FreeImage has changed.
    • Ruby 1.9.1 & Friends – Ryan Bigg has revised his big blog entry on how to get rails up and running on 1.9.1. It’s getting closer to prime time.
    • padlock_authorization – Simple object-based role authorization plugin. If I wasn’t rolling my own authorization I’d probably try this one next.
    • Glow – The BBC gets into the JavaScript library business. Big selling points appear to be downlevel browser and multiple version support.
    • Mercurial: The Definitive Guide – Bookmarking in case I’m ever forced to use Mercurial.
    • Phoenix – Real-time editing for web pages, including HTML, CSS, and JavaScript, within the confines of Firefox.
    • Announcing Appsta – Gem that extends the templating facility in Rails 2.3 with knowledge of GitHub and Heroku, among other things.

    Big Old Rails Template

    A few people have asked me about the Rails application template that I’ve put together recently. For those who are interested, it’s now available for review and download as a gist. To use it, just specify the -m switch when creating a Rails application:

    rails new_app_name -m lark_template.rb

    I should warn you of two things. First, it’s a pretty heavyweight template, sticking a lot of stuff into the new application. This suits me, because I have a lot of things I use in just about every application, but it may not suit you. Second, Rails templates are not one-size-fits-all; you’d be better off treating this as a starting point to steal from than a finished template to use (though if you want to use it, feel free).

    Here’s a list of what this template sets up:

    Coding Tools

    • Authlogic for user authentication, including password resets, anonymous_only, authenticated_only, admin_only application helpers
    • World’s simplest authorization system: manage multiple string roles on users with User#add_role, User#remove_role, User#clear_roles, and User#has_role?
    • Date formats: :us, :us_with_time, :short_day, :long_day
    • live-validations for client-side JavaScript data entry validation. Add :live_validations => true to form_for declarations to hook this up.
    • Paperclip for attachment management
    • /pages/css_test will show most CSS styles in action
    • Searchlogic for magic named scopes and search forms – Includes attribute_equals, attribute_does_not_equal, attribute_begins_with, attribute_like, attribute_ends_with, attribute_greater_than, attribute_null, attribute_blank etc. etc.
    • Stringex for extra string functionality – acts_as_url, String#to_ascii, String#to_html, String#to_url, String#remove_formatting, String.random
    • US State application helpers
    • will-paginate for pagination

    Database Tools

    • Hooked up for PostgreSQL
    • admin-data plugin for administrative UI. http://localhost:3000/admin_data will get you to the application’s data. On production, only admin can view data, no one can edit (modify config/initializers/admin_data.rb to adjust this)
    • db-populate for seed data

    Deployment Tools

    • fast_remote_cache strategy for deployment
    • rubiadhstrano for deployment recipes; automatically uses multiple targets, so: cap production deploy for deployment to production
    • superdeploy for additional Capistrano tasks. cap -T for full list.

    External Services

    • Exceptional for error tracking. Go to /pages/kaboom to test after finishing Exceptional setup.
    • New Relic for performance tracking

    Testing Tools

    • Shoulda and Test::Unit for testing
    • Mocha for mocking
    • Object Daddy for factories
    • Generated code is already covered by tests
    • parallel-test for faster testing. rake test:parallel:prepare[2] to set up two test databases. rake test:parallel[2] to distribute tests across two cores
    • rack-bug for request/response/perf analysis. http://localhost:3000/__rack_bug__/bookmarklet.html to add bookmarklet to browser.
    • shmacros for additional Shoulda macros: should_accept_nested_attributes_for, should_act_as_taggable_on, should_callback, should_delegate, more
    • More extra shoulda macros: should_have_before_filter, should_have_after_filter
    • metric-fu for static code analysis. rake metrics:all, configure in Rakefile
    • inaction-mailer is installed for development environment, so mails sent during dev will end up as files in /tmp/sent_mails

    Double Shot #493

    There are days I need to remind myself that I’m happier on the open source side of the fence.

    This Week in Edge Rails

    This post is by Mike Gunderloy from Riding Rails - home

    Click here to view on the original site: Original Post

    April 18, 2009 – April 24, 2009

    Edge Rails has been undergoing major surgery for the past week, as the core team gets ready for a Rails 3.0 alpha release at RailsConf. We saw about 50 commits to the master branch in GitHub this week. Here’s a quick overview of the recent changes.

    Rails 2.3.x Changes

    Before digging into the changes on the master branch, there were a few things committed to the 2-3-stable branch. If you’re running on 2.3 edge, these are ready for you; they’re also ported to the master branch already.

    • A couple of bugs involving associations with hash conditions have been fixed, notable to make sure that :dependent => :delete will work.
    • The PostgreSQL Active Record adapter now does the right thing if you use tables in non-default schemas. You need to set the table name in your model class, of course: set_table_name 'other_schema.customers' commit
    • Also in the PostgreSQL adapter, a couple of bugs related to wrong quoting of names with capital letters are fixed.

    ActionView::Path Refactoring

    One major chunk of change in Rails 3 this week comes from the continued work to refactor Action Pack. This time, ActionView::Path was the target. Changes in commit include decoupling ActionView::Path from Action Controller and Action Mailer, which gives us two major benefits. First, consolidating similar code in one place makes it easier to understand and maintain. Second, by abstracting this stuff and giving it an API, we’ll make it possible for other components to participate in the controller layer, beyond mailers and traditional controllers.

    There’s also some work here to set up for the future. The plan is to decouple templates from the file system, and to decouple localization from ActionView. Stay tuned!

    Pluggable JSON Backends

    You may recall that recently Rails went to pluggable XML support. This week, thanks to work from Rick Olson, we have pluggable JSON. This means that you can replace the default YAML-based JSON support with the JSON gem:

    ActiveSupport::JSON.backend = "JSONGem" 

    As part of this change, Rails now uses ActiveSupport::JSON.encode() wherever it needs JSON. This replaces using #to_json, and Rails team is recommending that you do the same. If you do choose to use #to_json, you need to be aware that some libraries might override it. You can use this pattern to make sure that you’re getting Rails’ own definition of #to_json:

    gem 'json'
    # JSON gem loaded, which overwrites to_json
    ActiveSupport::JSON.backend = "JSONGem" 
    class ActiveRecord::Base
      # replace the gem's to_json with Rails' own to_json
      alias to_json rails_to_json

    Active Support à la carte

    In Rails 2.x, require "active_support" pulls in all core extensions at once. In Rails 3, require "active_support" only makes the extensions available; you have to explicitly require those you wish to use. Many of this week’s changes were concerned with breaking up Active Support so you can take just what you need and nothing more.

    The end result is that it’s easy to cherry-pick features from Active Support without feeling like you’ve invited a portly gentleman for a piggyback ride. As an added bonus, all core extension documentation is now consolidated in one place: the core class. You don’t have to go poking around every extension module to find a method.

    Internally, the core extensions have been reorganized so they can be directly required without assuming all of Active Support is available. Want inflections like "car".pluralize? require "active_support/core_ext/string/inflections" and you’ve got them. Note: the implementation and organization will change as we settle on the best way to provide core extensions.

    Other Edge Changes

    • The Rails extension to Pathname was dropped, since it was only used in one spot in the code. commit
    • Support for the DRb cache store has been removed. commit
    • The sqlite Adapter joins the PostgreSQL adapter in supporting microsecond resolution. commit

    2009 Rails Google Summer of Code Projects

    This post is by Mike Gunderloy from Riding Rails - home

    Click here to view on the original site: Original Post

    The Google Summer of Code program has announced this year’s funding winners, and Rails has four student slots. Here’s what our students will be working on this summer:

    Joshua Peek will be refactoring some of the Rails internals, with the goal of finishing the work on Active Model. The idea behind this particular Rails component is to extract some of the commonalities from Active Record and Active Resource, which in turn will make it easier to maintain the higher-level components and make the more consistent.

    Nelson Crespo is planning on adding some Dtrace probes into a Rack module. These probes should make it possible to see what’s going on in a Rails application (or any other Rack-based application) with much finer detail than can be easily retrieved now. When the probes are ready, he’ll be working up some visualizations.

    Jose Valim is tackling a rewrite of the Rails generator code. Right now, the generators are tightly-coupled to particular architectural choices; the goal is to make it possible to select, for example, a testing library, an ORM, and a Javascript library when you choose to generate a scaffold, and have the generated code use your preferred pieces.

    Emilio Tagua will be working on Active Relation. This is another refactoring of the ActiveRecord code, covering the query generation capabilities. With Active Relation as a separate component, Rails will be better positioned to move towards ORM agnosticism.

    We’d like to thank all of the students and mentors who participated in the Summer of Code selection process – it was tough to get down to four projects, considering all the great proposals we had. In particular, we had six runners-up whose proposals were excellent: Carlos Kirkconnell, Florian Gross, Hector Gomez, Ian Ownbey, Luciano Panaro, and Daniel Luz. We’re looking forward to seeing what all of our students bring to Rails this summer, and hope not to lose touch with others who are also excited about the prospects for Rails 3.0.

    Phusion Announces Passenger for Nginx

    This post is by Mike Gunderloy from Riding Rails - home

    Click here to view on the original site: Original Post

    In the relatively short time since its release, Phusion Passenger has become part of the preferred deployment strategy for many Rails applications. But because it’s targeted at Apache, some sites have been unable to use Passenger. Apache is a great full-featured web server, but for highly traffic nginx seems to consistently deliver better throughput at lower memory use.

    As of today, though, the Rails server landscape is changing for the better once again with the announcement of Phusion Passenger for Nginx. This new version takes the Passenger technology, including the use of Ruby Enterprise Edition, and integrates it tightly with nginx. How tightly? Well, you just install the Passenger 2.2.0 gem and run the included nginx installer, and you get a custom-built version of nginx along with instructions on how to configure it to server your Rails site. In addition to combining the benefits of nginx and Passenger, this has the side effect of greatly simplifying the nginx setup.

    For more details, including a screencast, hop on over to Phusion’s blog

    One Giant Leap Forward

    This post is by Mike Gunderloy from Riding Rails - home

    Click here to view on the original site: Original Post

    As of a few minutes ago, the first big bunch of Rails 3 changes were merged back to Rails master branch in github. This represents a good deal of work by Yehuda Katz, Carl Lerche, and others. I’ll have more to say on the changes later on this week, but for now, just a quick caution: if you’re in the habit of using Edge Rails, you should likely switch to the 2-3-stable branch for the time being. The master branch of Rails will likely take a little while to settle back into something that can be used for anything other than getting a preview of the Rails 3 excitement.

    Rails IDEs March On

    This post is by Mike Gunderloy from Riding Rails - home

    Click here to view on the original site: Original Post

    Many Rails developers are perfectly happy working on their code in a text editor – and there are certainly plenty of excellent text editors out there. But others, particularly those who have come to Rails from another platform, find themselves wanting a full integrated development environment. For the latter group of developers, there’s good news: two major cross-platform Rails IDEs have releases available now.

    Aptana’s RadRails (a plugin for their Aptana Studio IDE) has just released version 1.2. This Eclipse-based environment will seem instantly familiar to many users, and version 1.2 has a couple of major advances to boast about. First, it includes a wizard that will aid new users in setting up Ruby, Gems, and Rails; this is likely to be especially useful to those coming to Rails on Windows. Second, it has built-in deployment to Aptana’s Cloud Connect scalable deployment service, giving a pain-free way to get your Rails applications up and running.

    Also worth a look is JetBrains’ RubyMine, currently in late beta prior to its commercial release. A purpose-built Rails IDE, it offers a variety of features including rake support, a model diagrammer, built-in web previews, and code quality tools. RubyMine isn’t finished yet, but the current beta version is showing good promise.

    Both RadRails and RubyMine have the features you’d expect from an IDE, including flexible code editors, refactoring support, built-in hooks for test running, integrated debugging, and source code integration. RadRails comes in both community and $99 Pro editions, while RubyMine is scheduled to be released at $99. Whether you prefer to work in a text editor or an IDE, the appearance of these applications is yet another sign of the continuing popularity and growth of the Rails ecosystem.