There have been some noteworthy changes to the Rails code base recently. I thought I’d list some of them here to familiarize myself (and others) with them:

  • You can now specify which plugins you want loaded, instead of having Rails assume you want to automatically load all plugins in the vendor/plugins folder. In config/environment.rb:
    config.plugins = %w[ textmate_footnotes acts_as_taggable ]
    

  • Namespaced Models! It’s now possible (and has been for some time, I believe) to create models like this:
    class Admin::Tools < ActiveRecord::Base; end
    


    The above example would reside in app/models/admin/tools.rb.

    Update: This feature is in Rails 1.1—thanks to Matthias for pointing out how out of date I am :P

    I think I’m going to find that it’s a lot easier to keep large applications organized, given that good applications often break concepts up in to small and manageable classes in the domain.

    Note that you can also use this ability with non-active-record classes as well–it’s just as valid to create a model that connects with your LDAP server or loads text files from disk. Namespacing is good :)

  • You can run your own script files on Unix-like systems like a real script, using script/runner. All it takes is adding the following shebang line (first line) to a ruby file:
    #!/usr/bin/env /path/to/my/app/script/runner

    This is similar to adding

    #!/usr/bin/env ruby

    to ruby files, but it gives you the whole Rails environment to work in as well.

  • The content_tag and form_tag helper methods now support blocks. This means you can enclose a bunch of HTML or more eRB in a block, and it’ll close the tags automatically for you at the end of your block.
    <% form_tag :action => "create" do %>
    HTML and Text goes here.
    <%= submit_tag "Done" %>
    <% end %>
    


    Functionality is similar for content_tag:

    <% content_tag :span, :class => "title" do %>
      <%= @names.join(", ") %>
      <%= image_tag "link.gif" %>
    <% end %>
    


    Produces:

    George, Tom, Lisa 
    

  • Some helpers have become deprecated:
    • start_form_tag / end_form_tag
    • link_to_image
    • link_to :post => true
    • others?