Matt, The photo does get saved. Everything is saved correctly
In the following: > redirect_to :action => "edit" , :id => @project.id, :photo => > @project.photo, :project_detail => @project.project_detail You are undoubtedly correct that it probably does not make sense. I was thrashing, my thought being that perhaps since I am editing a project page, I would need to provide the reference to the @project_detail and @photo instances. That was what I was attempting to do, since I do not know exactly how that would be done. Of course, the photo_id and project_detail_id are saved in the project record, but what I need to do is have an instance of them passed to the project edit page. I do not know how to do that. The reason for the very strange way I am going about this is: I am creating a page for a project. That page has 4 forms. 3 forms which reference the same photo record, which I use to upload 3 different image files. The photo record belongs_to the project. I need to save the project ahead of time so the id is available to the photo. I need to save the photo ahead of time so I am able to update that record 3 different times. That is why I am using a 'new' action to create the project, then redirect it to the project edit page: >What are you redirecting to? redirect_to :action => "edit" , :id => @project.id ( extra params deleted :) ) So that is what I am trying to do exactly. /*******************************************/ At this point what I need to know exactly is how to have the <form with="&[email protected]"> work on the project edit page. I do not understand why this is not working. /*******************************************/ Oh, and the photo model DOES NOT HAVE VALIDATIONS FOR CREATE. The validation will be in the posting of project_details. If you have a thought on how this could be designed to work with a different schema, would love to hear it. The last step in this design will be to use the iframe and 'responds_to_parent' to create an 'Ajaxy' page: The images will be uploaded, then displayed in the current page. A project_detail form will be filled out, then all elements validated. Cheers, Jet On Sep 13, 5:29 pm, Matt Jones <[email protected]> wrote: > On Sep 13, 2009, at 8:20 PM, blueHandTalking wrote: > > > > > > > Hi Brett, > > > Thank you for looking at this. I actually am saving the project > > so I can have the project_id available when I update the photo, > > since I update photo 3 times before the project_detail form is > > submitted. > > > I do not know why, but the project_id and the user_id are now being > > correctly > > saved. > > > However, by somehow fixing this (I believe the error previously was > > due to a typo in the photo model -- projecet_id --), I now have > > another problem: the form for the photo will not display. Here is how > > I changed the > > project controller: > > > def new > > �...@project = Project.new > > �[email protected] = current_user > > > �...@project_detail = @project.build_project_detail > > �...@project_detail.user = current_user > > �...@project_detail.save > > > �...@photo = @project.build_photo > > �[email protected] = current_user > > �[email protected] > > This is going to fail unless your photo model has no validations at > all on it. Almost certainly not what you want. > > > �[email protected]_id = @photo.id > > �[email protected]_detail_id = @project_detail.id > > �[email protected] > > > redirect_to :action => "edit" , :id => @project.id, :photo => > > @project.photo, :project_detail => @project.project_detail > > > end > > > Do I need to be passing some other information in my redirect? Setting > > up local vars? The form was actually coming up fine previously! > > What are you redirecting to? The extra params for photo and > project_detail don't make any sense, unless you're doing something > weird in your routing. > > > I am using > > > <form with="&[email protected]"> > > > in my application.dryml > > > Does the redirect interfere with Hobo knowing who the current user is? > > Or for security reasons is this info not passed along in redirect? > > As noted above, it's quite likely that the photo doesn't get saved, as > it fails validation when set up with build_photo. Alternatively, check > your permissions for Photo, as something must be wrong... > > --Matt Jones --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/hobousers?hl=en -~----------~----~----~----~------~----~------~--~---
