安装生成器将看不到我定义的方法

时间:2015-04-10 04:18:40

标签: ruby-on-rails ruby-on-rails-4 mongoid rails-engines forem

我正在尝试在另一个应用程序中使用我的引擎来测试安装生成器,它似乎失败了。我没有使用我的安装生成器很长一段时间,所以我不确定它何时崩溃(或者它是否真的顺利工作)。我的项目基于雷达/ forem,因此我尝试借用了很多代码(包括生成器)。

编辑:我的安装程序适用于引擎测试/虚拟但不适用于其他应用程序。为什么呢?

GH问题:https://github.com/NJayDevelopment/mongoid_forums/issues/16

这是日志:

$ rails g mongoid_forums:install
What is your user class called? [User] 
What is the current_user helper called in your app? [current_user] 
Defining mongoid_forums_user method inside ApplicationController...
      insert  app/controllers/application_controller.rb
Adding mongoid_forums initializer (config/initializers/mongoid_forums.rb)...
      create  config/initializers/mongoid_forums.rb
(erb):5:in `template': undefined method `per_page' for MongoidForums:Module (NoMethodError)
The route is successfully added, however the initializer/mongoid_forums.rb is a blank file. The method is defined exactly how radar/forem does it, what could be the error?

以下是相关代码:

每页方法定义:https://github.com/NJayDevelopment/mongoid_forums/blob/master/lib/mongoid_forums.rb#L33

Mattr访问者: https://github.com/NJayDevelopment/mongoid_forums/blob/master/lib/mongoid_forums.rb#L9

初始化模板: https://github.com/NJayDevelopment/mongoid_forums/blob/master/lib/generators/mongoid_forums/install/templates/initializer.rb

在错误点安装生成器: https://github.com/NJayDevelopment/mongoid_forums/blob/master/lib/generators/mongoid_forums/install_generator.rb#L47

1 个答案:

答案 0 :(得分:0)

当您尝试在pry中使用mongoid_forums时,您会发现涉及装饰器的错误发生。这个问题在我对装饰器的拉动请求中得到修复:parndt / decorators#13

这是因为需要文件的方式以及在那里调用load!的方式。

等待PR状态,这与雷达/ forem使用的版本相同。