Hello all,
I have two models (Gallery and Gallery_Image). Gallery_Image has a
gallery_id property that acts as a foreign key. The model files look as
follows:
class Gallery < ActiveRecord::Base
has_many :Gallery_Images
end
class GalleryImage < ActiveRecord::Base
belongs_to :Gallery
end
I altered the _form.rhtml file for Gallery_Image to look like the
following:
<%= error_messages_for ‘gallery_image’ %>
Caption
<%= text_field 'gallery_image', 'caption' %>
Thumbnail path
<%= text_field 'gallery_image', 'thumbnail_path' %>
Fullsize path
<%= text_field 'gallery_image', 'fullsize_path' %>
Gallery
<%= @galleries = Gallery.find(:all, :order => "name")
collection_select(:gallery_id, :gallery_id, @galleries, :id, :name)
%>
The gallery_id value is not being set in the database. Do I need to do
something in the controller? I know this is a stupid noob question, but
I would very much appreciate the help.
Also, should I move the “@galleries = …” part into the
gallery_images_controller and out of the view? I would think that I
should, but it looks like it would end up being repeated in the
controller (since it would have to be there for both new and update).
Any thoughts?
Thanks,
Will
Get your email and more, right on the new Yahoo.com