has_many questions

I am working on a project where I am uploading data about houses and need pictures to accompany it. I have a model for 'housing' and another one for picture. my housing class has_many :picture

and my picture class belongs_to :housing

My questions are

1. I want to use one form to create a new house with a bunch of pictures. how do I do this

2. a scaffold can generate the traversal of my housing table in my view, but how do I display the pictures.

3. I was told to use attachment_fu, and the tutorial was great at telling me how to upload an image, but it didn't show how to link an image to another model.

4. when I generate a scaffold via "ruby script/generate scaffold housing add_housing" why don't the forms contain the logic to upload pictures with the housing data.

I have been relying on books and google searches to get me started, but they have only discussed single models, and I haven't found a good resource for doing what I need. Any help would be greatly appreciated. It doesn't even have to be the answer, so long as it points me to something that will explain what is going on and help me get this done.

jvazquez wrote:

1. I want to use one form to create a new house with a bunch of pictures. how do I do this

Don't. Create another action for that. It gets pain in the ass to handle image post data on edits :slight_smile:

2. a scaffold can generate the traversal of my housing table in my view, but how do I display the pictures.

Use the docs, Luke! with attachment_fu you do @picture.public_filename.

3. I was told to use attachment_fu, and the tutorial was great at telling me how to upload an image, but it didn't show how to link an image to another model.

Well... @picture = @housing.pictures.build(params[:picture]) @picture.save

4. when I generate a scaffold via "ruby script/generate scaffold housing add_housing" why don't the forms contain the logic to upload pictures with the housing data.

Don't expect scaffold to be 'oh mighty God'. It's only for starters and isn't suited well for most cases in life.