当前位置: 首页 > 知识库问答 >
问题:

使用ActionController::Responder和axlsx_rails gem设计身份验证错误

程瑞
2023-03-14

在使用Devise进行身份验证的现有Rails 4.2.0应用程序中,添加了一个带有axlsx和axlsx_rails gem的export-to-xlsx选项。导出到xlsx现在可以正常工作:

app/controllers/cases_controller.rb:

class CasesController < ApplicationController
  def create
  ⋮
    @public_fields = public_fields

    respond_to do |format|
      ⋮
      format.xlsx { render :xlsx => "create", :filename => "cases.xlsx" }
    end

  end

end
wb = xlsx_package.workbook

wb.add_worksheet(name: 'Cases') do |sheet|
    sheet.add_row @public_fields

    @cases.each do |kase|
      sheet.add_row( @public_fields.map { |field| kase[field] } )
    end
end
NoMethodError in Users::SessionsController#new
undefined method `call' for ActionController::Responder:Class
(options.delete(:responder) || self.class.responder).call(self, resources, options)
responders (2.1.0) lib/action_controller/respond_with.rb:203:in `respond_with'
devise (3.4.1) app/controllers/devise/sessions_controller.rb:11:in `new'
actionpack (4.2.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:234:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in `block in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:151:in `block in halting_and_conditional'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_process_action_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.0) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal.rb:236:in `block in action'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:in `serve'
actionpack (4.2.0) lib/action_dispatch/routing/mapper.rb:49:in `serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.6.0) lib/rack/etag.rb:24:in `call'
rack (1.6.0) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.0) lib/rack/head.rb:13:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.0) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.0) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
activerecord (4.2.0) lib/active_record/migration.rb:378:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
web-console (2.0.0) lib/action_dispatch/debug_exceptions.rb:18:in `middleware_call'
web-console (2.0.0) lib/action_dispatch/debug_exceptions.rb:13:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.0) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.0) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.0) lib/rack/lock.rb:17:in `call'
actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
rack (1.6.0) lib/rack/sendfile.rb:113:in `call'
railties (4.2.0) lib/rails/engine.rb:518:in `call'
railties (4.2.0) lib/rails/application.rb:164:in `call'
rack (1.6.0) lib/rack/content_length.rb:15:in `call'
thin (1.5.1) lib/thin/connection.rb:81:in `block in pre_process'
thin (1.5.1) lib/thin/connection.rb:79:in `catch'
thin (1.5.1) lib/thin/connection.rb:79:in `pre_process'
thin (1.5.1) lib/thin/connection.rb:54:in `process'
thin (1.5.1) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.0.5) lib/eventmachine.rb:187:in `run_machine'
eventmachine (1.0.5) lib/eventmachine.rb:187:in `run'
thin (1.5.1) lib/thin/backends/base.rb:63:in `start'
thin (1.5.1) lib/thin/server.rb:159:in `start'
rack (1.6.0) lib/rack/handler/thin.rb:19:in `run'
rack (1.6.0) lib/rack/server.rb:286:in `start'
railties (4.2.0) lib/rails/commands/server.rb:80:in `start'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:80:in `block in server'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:75:in `tap'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:75:in `server'
railties (4.2.0) lib/rails/commands/commands_tasks.rb:39:in `run_command!'
railties (4.2.0) lib/rails/commands.rb:17:in `'
bin/rails:8:in `require'
bin/rails:8:in `'
spring (1.3.3) lib/spring/client/rails.rb:27:in `load'
spring (1.3.3) lib/spring/client/rails.rb:27:in `call'
spring (1.3.3) lib/spring/client/command.rb:7:in `call'
spring (1.3.3) lib/spring/client.rb:26:in `run'
spring (1.3.3) bin/spring:48:in `'
spring (1.3.3) lib/spring/binstub.rb:11:in `load'
spring (1.3.3) lib/spring/binstub.rb:11:in `'
/Users/collin/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/collin/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
bin/spring:13:in `'
bin/rails:3:in `load'
bin/rails:3:in `'

共有1个答案

陈允晨
2023-03-14

Noel(来自评论)是正确的:我在Rails4.2中使用了错误版本的axlsx_rails。我把它修好了,它工作得很好。

 类似资料:
  • 我正在尝试在 Swift 中创建一个 iOS 应用程序,该应用程序使用 AWS Lambda 使用以下身份验证服务 - https://github.com/danilop/LambdAuth 它使用适用于 iOS 的 AWS 移动开发工具包与迪纳摩数据库和 Lambda 进行通信 - http://docs.aws.amazon.com/mobile/sdkforios/developergui

  • 问题内容: 确保GWT + Tomcat应用程序执行身份验证和授权的最佳策略是什么? 问题答案: 有两种基本策略: 确保入口点; 保护远程服务。 最简单的方法是使用常规的Web应用程序安全工具来限制对GWT生成的html / js文件的访问: 春季安全; web.xml约束。 这样可以让您拥有eg 和。 保护远程服务 如果上述解决方案还不够,您可以进行更深入的研究。我已经通过Spring Secu

  • 问题内容: 我在jenkins中有sh脚本,其中包含sudo ssh命令,并且出现此错误 我发现解决方案说添加 这些行在/ etc / sudoers中,但仍然无法正常工作。 问题答案: 在最后添加添加以下行。

  • cluster=hfactory.getOrCreateCluster(“test cluster”,“localhost:9160”,凭据); 但不幸的是,它给了我一个错误: HFactory类型中的方法getOrCreateCluster(String,CassandraHostConfigurator,Map)不适用于参数(String,String,Map)

  • 问题内容: 我可以不用密码就可以将Node应用程序连接到Redis,但是添加密码后,我无所事事。 这是我的代码,摘自一个示例: 在运行应用程序时,我得到以下堆栈跟踪: 生成该行的行是最后一个-如果我注释掉尝试设置RedisStore的尝试,则不会出现任何错误。 我确定密码正确(我可以在redis- cli中进行验证,如果我将密码更改为错误,则可以验证auth回调不会触发)。如果我删除密码并注释掉两

  • 身份验证 PDF版下载 企业应用中的URL链接可以通过OAuth2.0验证接口来获取员工的身份信息。 通过此接口获取员工身份会有一定的时间开销。对于频繁获取员工身份的场景,建议采用如下方案: 企业应用中的URL链接直接填写企业自己的页面地址; 员工跳转到企业页面时,企业校验是否有代表员工身份的cookie,此cookie由企业生成; 如果没有获取到cookie,重定向到OAuth验证链接,获取员工