我在处理draper gem时遇到了一些问题。
安装draper 宝石' draper'
$ bundle install
这是成功的。
做了rails generate draper:install
$ rails generate draper:install
但是我遇到了一些错误
Expected string default value for '--test-framework'; got false (boolean)
Expected string default value for '--helper'; got true (boolean)
Expected string default value for '--assets'; got true (boolean)
Expected string default value for '--test-framework'; got false (boolean)
Expected string default value for '--helper'; got true (boolean)
Expected string default value for '--decorator'; got true (boolean)
Expected string default value for '--decorator'; got true (boolean)
Expected string default value for '--jbuilder'; got true (boolean)
Could not find generator draper:install.
没关系,我做了rails generate decorator Service
Expected string default value for '--test-framework'; got false (boolean)
Expected string default value for '--helper'; got true (boolean)
Expected string default value for '--assets'; got true (boolean)
Expected string default value for '--test-framework'; got false (boolean)
Expected string default value for '--helper'; got true (boolean)
Expected string default value for '--decorator'; got true (boolean)
Expected string default value for '--decorator'; got true (boolean)
Expected string default value for '--jbuilder'; got true (boolean)
Expected string default value for '--test-framework'; got false (boolean)
create app/decorators/service_decorator.rb
这是成功的。
在services_decorator中制作方法
class ServiceDecorator < Draper::Decorator
delegate_all
def hello
'hello'
end
end
从视图
调用此方法<%= Service.first.decorate.hello %>
但这是错误,
Could not infer a decorator for ActiveRecord::Base.
有人可以教我什么是错的以及如何解决这个问题? rails版本为4.1.7,draper版本为2.1.0
答案 0 :(得分:1)
要在使用rails生成器时删除错误,请将<fieldset>
<legend>Reliable</legend>
<div>More text here</div>
<div>More text here</div>
<div>More text here</div>
<div>More text here</div>
<div>More text here</div>
<div>More text here</div>
<div>More text here</div>
<div>More text here</div>
<div>More text here</div>
</fieldset>
版本更改为0.19.1
并尝试添加到gem thor
application.rb