class Rollout < ActiveRecord::Base has_many :items,:through => :rollout_itemsendclass RolloutItem < ActiveRecord::Base belongs_to :rollout belongs_to :itemendclass Item < ActiveRecord::Base has_many :rollouts,:through => :rollout_itemsend
控制器:
def new @rollout = Rollout.newend
我使用以下表单得到上述错误:
<%= simple_form_for @rollout do |f| %> <%= f.association :items %><% end %>解决方法 Rollout和RolloutItem之间缺少关系:
class Rollout < ActiveRecord::Base has_many :rollout_items # This. has_many :items,:through => :rollout_itemsend
Item也是如此.
总结以上是内存溢出为你收集整理的ruby-on-rails-3 – 简单形式关联为nil提供了“未定义的方法`klass”:NilClass“错误全部内容,希望文章能够帮你解决ruby-on-rails-3 – 简单形式关联为nil提供了“未定义的方法`klass”:NilClass“错误所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)