Getting Started

Simple Tutorials

Here are some more simple tutorials, which are designed to show quick, simple, detailed examples of streamlined features and how to use them.

Coffee Example

So you say you're ready to stop banging rocks together, huh? You've come to the right place. Let's take Streamlined for a spin!


The following steps assume you're using Rails 1.2.3 and Streamlined Edge. Streamlined Edge has many new features and fixes not found in the latest stable version (0.0.7.1) - so until a new stable release is out, its recommended that you use edge.

First, lets create a quick application to keep track of our coffee, because we, as programmers, love coffee.

rails coffee  
cd coffee

Now we need a database for dev and testing:

mysql -u root
create database coffee_development
create database coffee_test
exit

# open up the "config/database.yml" file in your favorite text editor and edit the MySQL settings.

Lets generate a Coffee model and controller to play with, and also add some fields via our first migration.

script/generate model coffee
script/generate controller coffees
# open up the "001_create_coffees.rb" migration in your favorite text editor and edit the following

class CreateCoffees < ActiveRecord::Migration
  def self.up
    create_table :coffees do |t|
      t.column :brand, :string
      t.column :name, :string
      t.column :description, :string
      t.column :fair_trade, :boolean
    end
  end

  def self.down
    drop_table :coffees
  end
end

Now run the migration and open a server, just to make sure things work alright with your basic rails app:

rake db:migrate
script/server

Hit your app at http://localhost:3000 to make sure Rails is playing nice. If you see the standard Rails welcome page, you are all good.

Now install the Streamlined plugin and implement Streamlined into your CoffeesController.

script/plugin install http://svn.streamlinedframework.org/edge/streamlined/

# Once that is done, edit coffee_controller.rb to add streamlined
class CoffeesController < ApplicationController
  layout "streamlined"
  acts_as_streamlined
end

Now open up http://localhost:3000/coffees to view your Streamlined controller. You should see something like the following:

You'll notice that out of the box we get an Ajax-sortable table with no records in it, a live search in the upper right corner, and four buttons in the lower right: one to create a new coffee and three buttons to do export in different data formats.

We also have a tab on the left and a top on the right, both of which simply say "TBD" because Streamlined wants you to supply the link details. Lets change that and also add our own header and footer for this app by editing app/helpers/coffees_helper.rb.

module CoffeesHelper
  def streamlined_side_menus
    [ ["List All Coffee", {:controller => "coffees", :action => "list"}] ]
  end
  
  def streamlined_top_menus
    [ ["Add coffee", {:controller => "coffees", :action => "new"}] ]
  end
  
  def streamlined_branding
    link_to "Coffee Attack!", "/"
  end

  def streamlined_footer
    "Brought to you by #{ link_to "Caffeine", "http://en.wikipedia.org/wiki/Caffeine" }"
  end
end

Here we are overriding some Streamlined methods that get called in rendering the view to change the link text and add our own branding. Go ahead and click on the "Add Coffee" link and add some records with dummy data to get started. Once you have some records to play with, you can sample the filters and sorting.

You may also have noticed that the field order on both the list and new pages are just random and not the most user friendly. Lets fix that next - add a directory called "streamlined" under the app folder, and create a new file called "coffee_ui.rb" in that directory.

We are going to define the order of the columns to be sensible, and also other things...

Platform Specific remarks: FreeBSD 6.2 Ruby 1.8.6.111_1 Ruby18-gems 0.9.4 Rubygem-rake 0.7.3 MySQL 5.0.51 Rails 2.0.2 streamlined "Edge"

The directory/subdir where you start the WEBrick server affects the application. Example: # cd /usr/local/www/rails/coffee # script/server makes the coffee application available # cd /usr/local/www/rails/states # script/server makes the states application available

You may encounter cookie errors that disappear with a refresh request. Be careful to follow each step in the tutorial exactly - Most problems occur by skipping a step. By default the database is sqlite3 in the database.yml file, you will have to install it or modify the application specific database.yml You may have to modify enviroment.rb and change RAILS_GEM_VERSION = "1.2.3" to your installed version

in progress.…

Attachments