Forum: Ruby on Rails find not working properly

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
366eabff1518dd0374338d266532b5b3?d=identicon&s=25 Robert McGinley (Guest)
on 2006-06-01 17:33
here is the input view
[code]
<form method="post" action="found">
<br>
<b>Find by</b><br/>
<b>Vehicle Number:</b><br/>
<input id="truck_vehicleID" name="truck[vehicleID]" size="20"
type="number" value=""/><br/>

</p>

<%= link_to "Find", :action => "found", :id => "@truck_vehicleID" %>
</form>
[/code]

the controller
[code]
    def found
          @truck = Truck.find(:all,  :conditions => "trucks.vehicleID =
'truck_vehicleID'")
          @oil = Oil.find(:all, :conditions => "vehicleID =
'truck_vehicleID'")
          @apperance = Apperance.find(:all, :conditions => "vehicleID =
'truck_vehicleID'")
          @brake = Brake.find(:all, :conditions => "vehicleID =
'truck_vehicleID'")
          @inspection = Inspection.find(:all, :conditions => "vehicleID
= 'truck_vehicleID'")
          @rdifferential = Rdifferential.find(:all, :conditions =>
"vehicleID = 'truck_vehicleID'")
          @tow = Tow.find(:all, :conditions => "vehicleID =
'truck_vehicleID'")
          @tred = Tred.find(:all, :conditions => "vehicleID =
'truck_vehicleID'")
          @repair = Repair.find(:all, :conditions => "vehicleID =
'truck_vehicleID'")
    end
[/code]

and the output view (partial too big to put all here)
[code]
<% @truck.each do |truck|%>
<tr>
	<td><%= truck.vehicleID%></td>
	<td><%= truck.vin%></td>
	<td><%= truck.plate%></td>
	<td><%= truck.curmileage%></td>
	<td><%= truck.oilInt %></td>
</tr><p>
<% end %>
[/code]

The variable doesn't get passed properly so the found always comes up
with vehicleID 0.  I don't know if i have it named wrong in the
controller or what.
I have overriden the primary key in certain ways.  (not the
set_primary_key because that does not allow you to manually write the
primary key.  I am not useing auto increment because the primary key is
representing a truck #)  IF you need to seem more of the code let me
know.
366eabff1518dd0374338d266532b5b3?d=identicon&s=25 Robert McGinley (Guest)
on 2006-06-01 18:05
I changed it to

    def found
          @truck = Truck.find(@params["id"])
          @oil = Oil.find(:all, :conditions => ["vehicleID =
:Truck_vehicleID", params])
          @apperance = Apperance.find(:all, :conditions => "vehicleID =
'truck_vehicleID'")
          @brake = Brake.find(:all, :conditions => "vehicleID =
'truck_vehicleID'")
          @inspection = Inspection.find(:all, :conditions => "vehicleID
= 'truck_vehicleID'")
          @rdifferential = Rdifferential.find(:all, :conditions =>
"vehicleID = 'truck_vehicleID'")
          @tow = Tow.find(:all, :conditions => "vehicleID =
'truck_vehicleID'")
          @tred = Tred.find(:all, :conditions => "vehicleID =
'truck_vehicleID'")
          @repair = Repair.find(:all, :conditions => "vehicleID =
'truck_vehicleID'")
    end

now i can get the right truck but not the sub data.  I'm working on
getting the rest but a push in the right direction would be helpfull.
This topic is locked and can not be replied to.