Oomoo

March 5, 2008

A Simple Drill Down

Filed under: model, rails, ruby — oomoo @ 11:09 pm

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.html.erb
< p > Find me in app/views/orders/ list .html.erb </ 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.html.erb 
< p > Find me in app/views/orders/show.rhtml </ p >
Order #: <% = @order . ord Number %>< br />
Customer PO #: <% = @order.ordCustPONum %>< br />

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: