Rails_admin未定义的方法'field'具有许多关联

时间:2014-12-29 07:24:18

标签: ruby-on-rails rails-admin

我在使用rails admin gem& amp;有很多协会。我一直收到这个错误:"未定义的方法`字段'为#"第一次访问我的/管理面板时。如果我刷新页面,它会加载页面,似乎工作正常。我的model / section.rb如下:

class Section < ActiveRecord::Base
belongs_to :course
has_many :quizzes, foreign_key: "lesson_id"
has_many :lessons, foreign_key: "section_id"#, :inverse_of => :sections
accepts_nested_attributes_for :lessons

rails_admin do
   create do
    field :course do
      default_value do
        Course.last.id
      end
     end
    field :title
  end

edit do
  field :course do
      default_value do
        Course.last.id
      end
  end
  field :title
end
end

 rails_admin do
   configure :lessons do
     field :title  # This is the line that is giving the error
     field :body
     field :image

    end
end

end

我的模特/ lesson.rb看起来像:

class Lesson < ActiveRecord::Base

 belongs_to :section #, foreign_key: "section_id"#, :inverse_of => :lessons
 has_many :posts, foreign_key: "lesson_id"
 has_one :quiz, :inverse_of => :lesson
 accepts_nested_attributes_for :quiz

错误出现在字段:configure下的标题:课程。我的所有模型都有很多关联,我收到了这个错误。刷新页面(需要完成大约5/6次)显示了      mount_uploader:image,PictureUploader     端

0 个答案:

没有答案