代码之家  ›  专栏  ›  技术社区  ›  Trip

如何设置合适的选择表

  •  0
  • Trip  · 技术社区  · 14 年前

    @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 回复  |  直到 14 年前
        1
  •  0
  •   theIV    14 年前

    你试过以下方法吗?

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

    :再看一次你的表格,你在做什么 form_for :gallery . 做 Gallery 有一个名为 gallery Organization 那已经 ?