View Single Post
Old Jun 1st, 2006, 6:05 PM   #9
SirBob1701
Newbie
 
Join Date: May 2006
Posts: 20
Rep Power: 0 SirBob1701 is on a distinguished road
heres the create method
    def create
    @a_truck = Truck.new(@params['truck'])
    if @a_truck.save
        redirect_to :action => 'list'
        else
          render_action 'new'
        end
      end

the view
<form method="post" action="create">
<br>

<b>Vehicle Number:</b><br/>
<input id="truck_vehicleID" name="truck[vehicleID]" size="20" type="number" value=""/><br/>

<b>Vin:</b><br/>
<input id="truck_vin" name="truck[vin]" size="20" type="number" value=""/><br/>

<b>Current Mileage:</b><br/>
<input id="truck_curmileage" name="truck[curmileage]" size="20" type="number" value=""/><br/>

<b>Tag:</b><br/>
<input id="truck_plate" name="truck[plate]" size="20" type="text" value=""/><br/>

<b>Oil Change Interval:</b><br/>
<input id="truck_oilInt" name="truck[oilInt]" size="20" type="number" value=""/><br/>
</p>

<input type="submit" value="Create">
</form>

and just for measure the model
class Truck < ActiveRecord::Base
set_primary_key :vehicleID
  
  def before_create
    self.id = vehicleID
  end
  
  def before_update
    self.id = vehicleID
  end
	has_many :oils
  has_many :tows
  has_many :appearances
  has_many :brakes
  has_many :bridges
  has_many :inspections
  has_many :rdifferentials
  has_many :repairs
  has_many :treds
end

and i might replace the @oil = Oil.find(:all, :conditions => ['vehicleID = ?', id]) but right now i wanna take care of some other stuff i can go back to it.
SirBob1701 is offline   Reply With Quote