Weblog
Begin...Rescue - Starting Over with Ruby/Rails
I'm just a guy, Making the move from a Windows database tool to Ruby on Rails.


A Simple Drill-Down

A Simple Drill Down (list of orders to a single order)

Model

order.rb
class Order < ActiveRecord::Base
  def self .find_all_orders
    find( :all , :order => "id" )
  end
end

Controller
orders_controller.rb
def list
  @orders = Order.find_all_orders
end

Views
List .rhtml
< p > Find me in app/views/orders/ list .rhtml </ p >
< table class = "list" cellpadding = "0" cellspacing = "0">
  <% for order in @orders - %>
    < tr >
      <
td ><% = link_to ( h ( order . id ),
                            : action   => 'show' ,
                            : id => order )
%></ td >
      < td ><% = order . ordCustPONum %></ td >
      < td ><% = order . ordOEM %></ td >
      < td ><% = order . ordDescription %></ td >
      < td ><% = order . ordModelNum %></ td >
      < td ><% = order . ordSerialNum %></ td >
      < td ><% = order . ord Status %></ td >
    </ tr >
  <% end %>
</ table >


Show
.rhtml
< p > Find me in app/views/orders/show.rhtml </ p >
Order #: <% = @order . ord Number %>< br />
Customer PO #: <% = @order.ordCustPONum %>< br />


POSTED BY Just A Guy AT 1/07/2008 11:37 PM

0 COMMENTS

» POST A COMMENT  |  DIGG IT


« BACK HOME





MY PROFILE
Name: Just A Guy
Location: Atlanta, GA
I've been programming for over 20 years (started when I was 2). When Microsoft decided to end new releases of my favorite development tool, Visual FoxPro (VFP), I had to decide if I wanted to keep drinking the Redmond Kool-Aid or step off that treadmill. I'm a consultant, so I must be very productive to survive. I found Ruby and Rails. Most of what I post here will be things I had to learn the hard way and how I am making the transition from a Windows-based (mainly) desktop tool to open-source web-based tools. Also see http://oomoo.wordpress.com (begin...rescue is part of the Ruby exception handling)

RECENT POSTS
Using Legacy Table in Rails
What is a Model?
Public Models