On Rails的4当我执行了一个装饰我得到了以下错误RSpec的测试: /app/spec/decorators/my_decorator_spec.rb:3:in `<top (required)>': uninitialized constant MyDecorator (NameError)
我肯定失去了一些东西,但我不知道是什么。 我生成 rails g decorator My
使用Rails 5我加入了宝石 gem 'draper', '3.0.0.pre1'
然后当我打电话安装发电机,我得到一个错误 Could not find generator 'draper:install'. Maybe you meant 'devise:install', 'config:install' or 'responders:install'
什么林做错了这里?
我在app/decorators/post_decorator.rb中有PostDecorator类。 它有一个调用Devise的current_user方法的方法。它看起来像这样: class PostDecorator < Draper::Decorator
delegate_all
def voter
h.current_user
end
end