2012-07-26 49 views
0

我的路線Simple_form不能Rails中與模型繼承工作3

scope :module => "group" do 
    resources :groups do 
     resources :topics 
    end 
    end 

我的模型

class Post < ActiveRecord::Base 
    belongs_to :group 
end 

class Group < ActiveRecord::Base 
    has_many :posts 
end 

class Group::Topic < Post 
end 

我的形式:

<%= simple_form_for [@current_group, @topic], :html => {:id => "post_form", :class => 'form-horizontal'} do |f| -%> 
end 

的錯誤消息是

undefined方法`group_group_topics_path'爲

回答

1

我不認爲這種情況是在simple_form。最有可能你有你的路線錯誤,他們應該作如下更新:

scope :module => "group" do 
    resources :groups do 
    scope :module => :groups do 
     resources :topics 
    end 
    end 
end 

然後你會得到group_group_topics_path路線的工作。要查看所有主題路由,請在控制檯中輸入此命令:rake routes | grep 'topics'

+0

它不能工作,我認爲這是simple_form的問題 – why 2012-07-31 12:54:32

+0

你在https://github.com/plataformatec/simple_form/issues上打開了一個問題嗎?答案是什麼? – melekes 2012-08-01 14:53:25

+0

我不認爲它是多態的情況 – why 2012-08-01 15:05:49