![]() |
Manually add Primary key and Finds
I have the primary key for table truck set to be vehicleID and when i pass this method
:
def createalso I was wondering how i can display data from many finds. :
def found |
Quote:
Also, consider posting on one of the Ruby on Rails forums/mailing lists. They probably know a lot more about the details of the system. Quote:
|
I fixed the first problem. Now the find does display i just can't figure out the variable name passed into the controller right now it defaults to 0.
|
hers the input view
:
<form method="post" action="found">the controller :
def foundand the output view (partial too big to put all here) :
<% @truck.each do |truck|%>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. |
The controller seems odd. The code in it tries to find trucks with vehicleIDs equalling the string "truck_vehicleID".
Since vehicleID is the primary key, I suspect you could do something like: :
def found |
I actually broke it down like this and it works well.
:
def foundI'm still running into errors though trying to write the primary key manually. Gonna have to look into that. |
You should be able to replace lines like this:
:
@oil = Oil.find(:all, :conditions => ['vehicleID = ?', id]):
@truck = Truck.find(@params["id"]) |
Quote:
|
heres the create method
:
def createthe view :
<form method="post" action="create">and just for measure the model :
class Truck < ActiveRecord::Baseand 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. |
| All times are GMT -5. The time now is 1:23 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC