I have a photos model and a gallery model. The gallery model(I used nifty scaffold) just has one field, a gallery name. In my photo edit form I want to link each photo to a gallery, eg. I create 2 separate galleries 2009 and 2010, I want to have a dropdown list on each photo edit page with the list of galleries, so each photo can be placed in a gallery. I've been using this and this as starting points but I'm stuck, and can't get the galleries to appear in my photo form.
class Gallery < ActiveRecord::Base
has_many :photos
attr_accessible :name
end
class Photo < ActiveRecord::Base
belongs_to :gallery
accepts_nested_attributes_for :gallery, :allow_destroy => true
views/photos/_form.html.erb
<% form_for @photo, :html => { :multipart => true } do |photo_form| %>
<p>
<%= photo_form.label :title %><br />
<%= photo_form.text_field :title %>
</p>
<p>
<% photo_form.fields_for :gallery do |gal_form| %>
<%= gal_form.label :name %>
<%= gal_form.collection_select :gallery_id, Gallery.all, :id, :name %>
</p>
<% end %>
<p>
<%= submit_tag %>
</p>
<% end %>
Currently there is no dropdown list on the photo form page, though I'm not receiving any errors and there is no mention of it either in the page source. I'd appreciate any help or to be pointed in the right direction...