无法安装和使用" draper"宝石

时间:2017-06-07 03:23:37

标签: ruby-on-rails decorator draper

我在处理draper gem时遇到了一些问题。

  1. 安装draper     宝石' draper'

    $ bundle install
    
  2. 这是成功的。

    1. 做了rails generate draper:install

      $ rails generate draper:install
      
    2. 但是我遇到了一些错误

          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.
      
      1. 没关系,我做了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
        
      2. 这是成功的。

        1. 在services_decorator中制作方法

          class ServiceDecorator < Draper::Decorator
            delegate_all
          
            def hello
              'hello'
            end
          end
          
        2. 从视图

          调用此方法
          <%= Service.first.decorate.hello %>
          
        3. 但这是错误,

              Could not infer a decorator for ActiveRecord::Base.
          

          有人可以教我什么是错的以及如何解决这个问题? rails版本为4.1.7,draper版本为2.1.0

1 个答案:

答案 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