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
    @project.user = current_user

    @project_detail = @project.build_project_detail
    @project_detail.user = current_user
    @project_detail.save

    @photo = @project.build_photo
    @photo.user = current_user
    @photo.save

    @project.photo_id = @photo.id
    @project.project_detail_id = @project_detail.id
    @project.save

    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!
I am using

   <form   with="&@project.photo">

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?

    Cheers,

        Jet


On Sep 13, 9:51 am, Brett Nelson <[email protected]> wrote:
> Also your message mentioned you need the id of the project before you
> save the project. The project won't get an id until it is saved.
>
> Brett
>
> On Sep 13, 9:46 am, Brett Nelson <[email protected]> wrote:
>
> > Have you tried it like this?
>
> > new_photo = @project.build_photo # this should set the project_id in
> > the new photo record
> > new_photo.user = current_user  # you shouldn't have to call out the id
> > field names explicitly
> > new_photo.save
>
> > Or like this
>
> > new_photo = @project.photos.new # this should set the project_id in
> > the new photo record
> > new_photo.user = current_user
> > new_photo.save
>
> > Brett
>
> > On Sep 12, 10:12 am, blueHandTalking <[email protected]> wrote:
>
> > > I have the following relationships:
>
> > > Photo
> > >    belongs_to :user
> > >    belongs_to :project, :creator => true
>
> > > ProjectDetail
> > >    belongs_to :user
> > >    belongs_to :project, :creator => true
>
> > > Project
> > >   belongs_to :user, :creator => true
> > >   has_one       :photo
> > >   has_one       :project_detail
>
> > > With a 'new' method, I create a project in ProjectController.
> > > I set up and save all relationships manually. This I do because
> > > I need the id of project because I will be saving photo before I save
> > > the project. An abbreviated representation of this is:
>
> > > @project = Project.new
> > >     @project.user_id = current_user.id
> > >     @project.save
>
> > >     @project.build_project_detail
> > >     @project.project_detail.user_id = current_user.id
> > >     @project.project_detail.project_id = @project.id
> > >     @project.project_detail.save
>
> > >     @project.build_photo
> > >     @project.photo.user_id = current_user.id
> > >     @project.photo.project_id = @project.id
> > >     @project.photo.save
>
> > > The very strange behavior that is occuring is that everything is
> > > saved
> > > correctly,
>
> > >    EXCEPT
>
> > > @project.photo.project_id = @project.id
>
> > > What is perplexing about this is that the project_detail saves the
> > > @project.id,
> > > and basically the photo and project_detail model are pretty much the
> > > same.
>
> > > The photo model  uses :has_attached_file with Paperclip, if that is at
> > > all relevant.
>
> > > Would appreciate any thoughts, or suggestions as to how I may be able
> > > to track this
> > > down.
>
> > > Cheers,
>
> > >    Jet
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to