Topic: find not working
I have a small system started. Consists of two MySQL tables; contacts (with an id) and attempts (with an id and contact_id and a foreign key to contacts based on contact_id). Models are: Contact has_many :attempts; Attempt belongs_to :contact.
Models and Controllers and Views were created from command line through scaffold.
In the parent table's show view I've placed links to the child table's controller show method under which the find is "@attempts = Attempt.find(:all, :conditions => ["contact_id = ?",
session[:contactid]]).....(session.contacid was assigned in the parent table's controller show method).
The child tables show view code was replaced with the normal "list" code. This works.
In the scaffold script generated controller for the child table (attempts) the list method uses the following:
@attempt_pages, @attempts = paginate :attempts, :per_page => 10
which is, of course, different than the find I used under the show method.
My problem is editing the attempts records reflected in the show view (you indeed can edit from the list view). I haven't changed any of the edit code.
When edit is called from show, you can tell from the url that the appropriate id is passed. But by the time the form is displayed it does not have the record. I can't tell where it looses the record id. There is a find in the attempts_controller edit method (@attempt = Attempt.find(params[:id])) but edit.rhtml calls update assigning @attempt to :id. Then there is another find in attempts_controller update method (same as in edit).
I know this may be a terse listing of the problem but I'll provide anything else needed.
Please help, most all my hair is now gone.