包含do ..... end(错误的参数)错误

Pre*_*rem 7 ruby ruby-on-rails

我正在实现一个模块,并使用RoR ActiveSupport :: Concern功能将其包含在我的课程中.我正在使用包含在该模块中的do .... end块,但面对"包含do"行的错误"错误的参数数量(0表示1)".

module Icecream
  extend ActiveSupport::Concerns

  included do  #throws error wrong no of arguments(0 for 1))
    has_many :flavours
    scope :icecreams, ->{where("has_icecreams = ?", true)}
  end
.
.
.
.
.
end
Run Code Online (Sandbox Code Playgroud)

是否包括阻止甚至需要参数?

Pre*_*rem 15

哦....修好了......

愚蠢的拼写错误

延长ActiveSupport :: 关注点 应该引起关注

  • 救了我一个巨大的未来头痛.感谢您发布解决方案! (2认同)

Edg*_*ega 13

如果你这样做include ActiveSupport::Concern,你可能会遇到同样的问题extend ActiveSupport::Concern.