h1. stage h1. → 'stage' h1. Rails instructions h2. Installing
sudo gem install stage
h2. Demonstration of usage
$ ./script/generate stage product name:string cost:integer weight:integer
exists  app/models/
exists  app/controllers/
exists  app/helpers/
create  app/views/products
exists  app/views/layouts/
create  app/views/products/index.html.erb
create  app/views/products/show.html.erb
create  app/views/products/new.html.erb
create  app/views/products/edit.html.erb
create  app/views/products/_form.html.erb
create  app/views/products/_data.html.erb
create  app/models/product.rb
create  app/controllers/products_controller.rb
create  app/helpers/products_helper.rb
create  db/migrate
create  db/migrate/001_create_products.rb
route  map.resources :products
The controller generated:
class PagesController < ApplicationController
  # GET /pages
  # GET /pages.xml
  def index
    @pages = Page.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @pages }
    end
  end

  # GET /pages/1
  # GET /pages/1.xml
  def show
    @page = Page.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @page }
    end
  end

  # GET /pages/new
  # GET /pages/new.xml
  def new
    @page = Page.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @page }
    end
  end

  # GET /pages/1/edit
  def edit
    @page = Page.find(params[:id])
  end

  # POST /pages
  # POST /pages.xml
  def create
    @page = Page.new(params[:page])

    respond_to do |format|
      if @page.save
        flash[:notice] = 'Page was successfully created.'
        format.html { redirect_to(@page) }
        format.xml  { render :xml => @page, :status => :created, :location => @page }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @page.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /pages/1
  # PUT /pages/1.xml
  def update
    @page = Page.find(params[:id])

    respond_to do |format|
      if @page.update_attributes(params[:page])
        flash[:notice] = 'Page was successfully updated.'
        format.html { redirect_to(@page) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @page.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /pages/1
  # DELETE /pages/1.xml
  def destroy
    @page = Page.find(params[:id])
    @page.destroy

    respond_to do |format|
      format.html { redirect_to(pages_url) }
      format.xml  { head :ok }
    end
  end
end
The edit page:
  

Editing Page

<%= render :partial => "form" %> <%= link_to 'Show', @page %> | <%= link_to 'Back', pages_path %>
The form partial:
  <%
    submit_label = "Update"
    submit_label = "Create" if @page.new_record?
  -%>

  <%= error_messages_for @page %>

  <% form_for(:page, :action => url(:page,@page)) do %>
    <%= partial :data %>
    

<%= submit_button submit_label %>

<% end %>
The data partial (the show view calls this directly):

Title
<%= page_title_value %>

Content
<%= page_content_value %>

As you can see, there are <model>_<field>_value methods. These are defined in the pages helper:
module PagesHelper
  def page_title_value
    if @action_name == "show"
      h @page.title 
    else
      text_field_tag "page[title]",  @page.title
    end
  end

  def page_content_value
    if @action_name == "show"
      h @page.content 
    else
      text_field_tag "page[content]",  @page.content
    end
  end

end
I need to get more precise with the form helpers, but for now this will do. h2. Forum "http://groups.google.com/group/stonean_stage?hl=en":http://groups.google.com/group/stonean_stage?hl=en h2. How to submit patches The Clone URL: git://github.com/stonean/stage.git Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above. I'm new to git and this whole opensource project admin gig, so please be patient with my stumbling around. h2. License This code is free to use under the terms of the MIT license. h2. Contact Comments and suggestions are welcome via the "forum":http://groups.google.com/group/stonean_stage?hl=en