我有这个HAML
-content_for :primary_content do
#available-disclosures-container
.message-container.information-container
%h3=(t "headings.influencers.disclosures.new")
%p=raw((t "influencers.instructions.disclosures.new"))
=render "sidebar/disclosures/list", :disclosures => Disclosure.basics, :show_link => true, :selectable => true, :usable => false
#disclosure-form-container{:style => "display:none;"}
= form_for([:sidebar,@disclosure], :html => {:id => "disclosure-form", :remote => true}) do |f|
我不知道为什么,但这最后一行:
= form_for([:sidebar,@disclosure], :html => {:id => "disclosure-form", :remote => true}) do |f|
导致此错误:
undefined method `model_name' for NilClass:Class
和
6: =render "sidebar/disclosures/list", :disclosures => Disclosure.basics, :show_link => true, :selectable => true, :usable => false
7:
8: #disclosure-form-container{:style => "display:none;"}
9: = form_for([:sidebar,@disclosure], :html => {:id => "disclosure-form", :remote => true}) do |f|
10: %p
11: =f.label :display_as, (t :select_disclosure_type)
12: =f.select :display_as, options_from_collection_for_select(Disclosure.basics, :display_as, :name, f.object.display_as)
知道导致这个问题的因素是什么?
谢谢!
答案 0 :(得分:2)
这看起来不对:
= form_for([:sidebar, @disclosure]) do |f|
看起来您正在尝试使用侧边栏符号来生成路线,该侧边栏符号需要是公开所属的模型的实例才能工作。
很难确定,但也许这就是你要找的东西:
= form_for(@disclosure), :url => [:sidebar, @disclosure] do |f|