如何设置正确的选择表格

时间:2010-09-23 18:39:35

标签: ruby-on-rails ruby forms select

我试图将最终结果绘制为@gallery = whatever i choose in my select

  - form_for :gallery do |f|
    .grid_6.hr_dots.clear

    .exist_gal
      .grid_5
        %label 
          2. Or add to an existing Gallery
      .clear
      .grid_4
        = select @gallery, :gallery, options_for_select(@galleries.collect { |g| g.name }), {}, :class => "gallery_title"
      .grid_2
        = link_to 'add photos', new_photos_organization_media_gallery_url(@organization.id, @gallery.id), :class => 'button add_photos_btn'

我的控制器:

def new
  @gallery = Gallery.new
  @galleries = @organization.galleries
end

1 个答案:

答案 0 :(得分:0)

您是否尝试过以下操作?

    = f.select :gallery, options_for_select(@galleries.collect { |g| [g.name, g.id] }), {}, :class => "gallery_title"

编辑:再次查看您的表单,您正在form_for :galleryGallery是否有一个名为gallery的字段,或者Organizationgallery的字段?