English 中文(简体)
铁路:2个有条理的模型的 Nest版?
原标题:Rails: Nested Form for 2 Scaffolded Models?

我如何为2个有胆识的模型设定一个封套形式?

我有一个Syllabus模式,有许多代表团。 以前,设立特派团的唯一途径是采用Syllabus的封套形式(我用铁路预报)。 昨天,我决定,用户应当能够自己建立特派团,因此,我敲响了代表团的心声,同时绕过移民,从而为现有的特派团模式创造了所有控制者和看法。

www.un.org/spanish/ecosoc 因此,问题:。 现在我可以自行设立特派团,但当我试图通过Syllabus表格创建特派团时,我就错了“未定义的`虚拟教学'方法;Mission:0xb372ffc.>我猜测它试图通过Syllabus属属地,而Syllabus属属地,这些属地在飞行任务中界定。 (流系仅为Syllabus的特性)。

总而言之,当我只为代表团提供模式时, Nest带式表格就与“设计者”合作,但当我把代表团聚集一堂,这样就能够存在,我就不使用封套格式。

Because there were more than a couple files that may affect this, I created a gist. https://gist.github.com/2631734

以前,这些是应该通过的内容。

{"utf8"=>"✓",
"authenticity_token"=>"YxkzNmIJl0jBA467tdHP2zqNv22DgKrzSx+WCFgwKtk=",
"syllabus"=>
    {"category"=>"Technology and Internet",
    "difficulty"=>"Beginner",
    "title"=>"missions testing",
    "description"=>"deccrip",
    "missions_attributes"=>
        {"0"=>
            {"_destroy"=>"false",
            "title"=>"plz",
            "content"=>"<p>
	dad</p>
"
            }
        }
    },
    "commit"=>"Create Syllabus"
}
最佳回答

我把它说出来,但确实是迷惑不解的。 我确信,这样做有更好的办法,但经过几天的艰苦努力,我对这一解决办法感到比高兴:

  @syllabus = Syllabus.new(:title => params[:syllabus][:title], :category => params[:syllabus][:category], :difficulty => params[:syllabus][:difficulty], :description => params[:syllabus][:description], :author_id => current_user)

  @syllabus.save!

  params[:syllabus][:missions_attributes].each do |a, b|

    @mission = Mission.new(:title => b[:title], :content => b[:content], :syllabus_id => @syllabus.id, :author_id => current_user, :category => @syllabus.category)

    @mission.save!

    end
问题回答

我的最佳猜测是<条码>生育。 页: 1

current_user.creations.build(params[:syllabus]) 

系指任务收集,而不是提纲。 其类型难以确定,没有完全错误和用户模式。





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签