2013-08-24 51 views
0

我正在爲我的一個項目定製RailsAdmin。我想實現多選擇框像下面的多對多關聯Rails Admin HABTM Association in Views not displayed select box

enter image description here

我的班級是不同的(沒有球隊),我有旅遊和方案

導遊班

class Tour < ActiveRecord::Base 
    attr_accessible :name 

    has_and_belongs_to_many :programs 
end 

程序分類

class Program < ActiveRecord::Base 
    attr_accessible :name 

    has_and_belongs_to_many :tours 
end 

聯合表

class ProgramsTours < ActiveRecord::Migration 
    def change 
    create_table :programs_tours, :id => false do |t| 
     t.integer :program_id 
     t.integer :tour_id 
    end 
    end 
end 

該協會創建帶有標籤的下方多增的形式,我不知道我怎樣讓這個多選框,任何建議將是有益的。

enter image description here

+1

看看http://railscasts.com/episodes/17-habtm-checkboxes或修訂版在http://railscasts.com/episodes/17-habtm-checkboxes - 修改(如果你有一個專業賬戶) – 23tux

+0

Tux,感謝您的快速回復。我知道收集和選擇框。但是我不知道如何獲得像railsAdmin中上面的屏幕截圖所示的雙向選擇框。 – Senthil

回答

1
class Tour < ActiveRecord::Base 

    attr_accessible :name, :program_ids 

    has_and_belongs_to_many :programs 

end 


class Program < ActiveRecord::Base 

    attr_accessible :name, :tour_ids 

    has_and_belongs_to_many :tours 

end 
+0

感謝您的回答,我已經解決了這個:) – Senthil