加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails-3 – rails 3机架中间件问题,未定义方法`每个’

发布时间:2020-12-17 01:30:12 所属栏目:百科 来源:网络整理
导读:我想用机架中间件打印模板的主体.下面是我的设置…… #config/initializers/response_timer.rb class ResponseTimer def initialize(app) @app = app end def call(env) status,headers,response = @app.call(env) [status,response.body] end end #applicat
我想用机架中间件打印模板的主体.下面是我的设置……

#config/initializers/response_timer.rb
         class ResponseTimer
            def initialize(app)
                 @app = app
            end

            def call(env)
             status,headers,response = @app.call(env)
             [status,response.body]
            end

         end  


       #application.rb file
       config.middleware.use "ResponseTimer"

当我提出请求domainname / students /我收到以下错误.

undefined method `each' for #<String:0xd69a2e0>

请帮助.

解决方法

我通过将[status,response.body]更改为[status,[response.body]]来解决我自己的问题,将response.body放在数组中.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读