Getting started with Streamlined (part 1)

If you were one of the unfortunate souls who missed RailsConf this year, I’m sorry for you. If you happened to be at RailsConf but missed Justin Gehtland’s excellent Streamlined tutorial then you are truly of all people most pitiable.

On a more serious note, the tutorial was very good and has sparked a lot of interesting ideas for further enhancing Streamlined beyond its already hefty feature set. For those who don’t know, Streamlined is a Rails plugin that brings the declarative goodness of ActiveRecord to the UI. It enhances your views with full-featured scaffolds that include relationship management, quick adding of associated models, and much more.

If you haven’t played with Streamlined before, why not give it a try? With several fresh screencasts over at the blog, a bundle of new documentation, a new sample project, and version 1.0 on the horizon… there’s no time like the present.

Getting started with Streamlined is easy…

First, let’s create a new Rails application and install the plugin:

$ rails address_book
$ cd address_book
$ script/plugin install

Second, generate a controller and a model:

$ script/generate controller People
$ script/generate model Person

Third, make the controller Streamlined-enabled by adding this code to it:

class PeopleController < ApplicationController
  layout "streamlined"

Streamlined will assume that our controller name matches the name of the model the controller manipulates. The above example automatically uses the Person model we created.

Now let's setup the fields for our Person model. Open the migration at db/migrate/001_create_people.rb and edit it to look like this:

class CreatePeople < ActiveRecord::Migration
  def self.up
    create_table :people do |t|
      t.column :first_name, :string
      t.column :last_name, :string
      t.column :email, :string

  def self.down
    drop_table :people

Finally, let's start our server and open the application:

$ script/server
$ open http://localhost:3000/people

Note: If you're on Windows, the open command won't work. You'll need to open Internet Explorer or Firefox and navigate to localhost:3000/people manually.

You should see Streamlined's interface in your browser, along with an empty list of people. Click the plus icon to add a new person. Try clicking on a column to sort the list. You can also edit and view existing people in the list and filter the list using the text box on the top right of the page.

In my next post, we'll create a UI class to go along with our model. We'll begin adding declarations to the UI class to change the way Streamlined renders our data.

6 thoughts on “Getting started with Streamlined (part 1)

  1. Thanks for posting this. It helped me get rolling with Streamlined.

    Couple of things:

    1) Don’t forget to:

    a) update database.yml w/ appropriate ‘username’ and ‘password’ values;
    b) create (at least) the ‘address_book_development’ database from a MySQL client;
    c) run “rake db:migrate” from the command line

    before starting up the server & browsing to the application.

    2) I couldn’t get this to work on my Wintel box [Ruby 1.8.5, rails 1.2.3, …], even after deleting the source_cache file and:

    >gems update –system
    >gems update

    For some reason, the plugin wouldn’t install properly …

    However, Ubuntu (Dapper Drake), Ruby 1.8.4, rails 1.2.3, etc., all went smoothly.

  2. Pingback: puts”nonsense”) » Blog Archive » Streamlining Your Way to Rails

  3. Is it layout “streamlined”
    this is what u have

    layout ‘streamlined’
    this is what the streamlined screencast has

    tried both
    even tried gems update
    the error message I get on a windows machine is Template is missing

  4. MercedesAMG, make sure you’ve run the installer task that copies layouts, JavaScript, etc. to the correct directories:

    rake streamlined:install_files

    This task is supposed to get triggered on install, but sometimes it doesn’t. When it doesn’t, it has to be run manually.

  5. I had the same issue as MercedesAMG (trying to get streamlined up and running on a pc).

    rake streamlined:install_files

    got me through the missing layout issue. Now it seems that there are no default index.rhtml files or that my app can’t locate the default index.rhtml from streamlined.

    Dropping a dummy index in gets around the error but eliminates all of the basic streamlined stuff (like the basic CRUD functions)

    Any ideas?

  6. I’d be very interested to know how/why you chose Streamlined over ActiveScaffold. Any comments?

Comments are closed.