- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
最近继承了一个Rails + Spine.JS的项目。尽管它的主题不是非常神秘(面向营销:人们制作自己的邮件列表,在发送之前准备内容,实际发送等等),但是它的实现是具体的并且依赖于多个 Rails 覆盖(就像下面问题 #2 中指定的那样)。
我有两个问题需要帮助。
问题一:
要点:在 Spine.JS 应用程序(前端)中,我们得到了发票的预览操作,它应该(并且确实)打开一个新选项卡来执行此操作。在我真正做到之前,一切看起来都很正常。没有太多毫无意义的解释,下面是发生的事情:
Started GET "/me/invoices/22/preview?oauth_token=XE03DFCGyCDYjdu8oWuU9zrN56Z6Wr7eZDuIjCbT&origin=http://localhost:9294" for 94.26.14.131 at 2013-12-08 00:55:27 +0200
Oauth2Token Load (0.3ms) SELECT `oauth_tokens`.* FROM `oauth_tokens` WHERE `oauth_tokens`.`type` IN ('Oauth2Token') AND (invalidated_at IS NULL AND authorized_at IS NOT NULL and token = 'XE03DFCGyCDYjdu8oWuU9zrN56Z6Wr7eZDuIjCbT') LIMIT 1
Processing by InvoicesController#preview as HTML
Parameters: {"oauth_token"=>"XE03DFCGyCDYjdu8oWuU9zrN56Z6Wr7eZDuIjCbT", "origin"=>"http://localhost:9294", "id"=>"22"}
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 270932 LIMIT 1
Invoice Load (0.2ms) SELECT `receipts`.* FROM `receipts` WHERE `receipts`.`type` IN ('Invoice') AND `receipts`.`id` = 22 LIMIT 1
Completed 500 Internal Server Error in 8.3ms
NoMethodError (undefined method `identifier' for "preview":String):
newrelic_rpm (3.6.9.171) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:157:in `render_with_newrelic'
actionpack (3.2.16) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.2.16) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.2.16) lib/abstract_controller/rendering.rb:110:in `_render_template'
actionpack (3.2.16) lib/action_controller/metal/streaming.rb:225:in `_render_template'
actionpack (3.2.16) lib/abstract_controller/rendering.rb:103:in `render_to_body'
actionpack (3.2.16) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
actionpack (3.2.16) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
actionpack (3.2.16) lib/abstract_controller/rendering.rb:88:in `render'
actionpack (3.2.16) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.2.16) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.2.16) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
……等等。如您所见,preview
一词是 Controller 操作的名称。
删除 NewRelic 没有帮助。然后错误被替换为:
NoMethodError (undefined method `formats' for "preview":String):
顺便说一句,Ruby 是 2.0.0-p353,而 Rails 是 3.2.16。 Rails 项目有一些自定义设置,例如大多数操作的 OAuth 参数——因为 Rails 应用主要是 Node.JS 项目的服务器存储单元。
查看 API 文档(如此处:http://www.rubydoc.info/docs/rails/3.1.1/ActionView/Template)给我的印象是 determine_template
Rails 方法(以及第二种情况下的未指定方法,没有 newrelic_rpm
) 不返回 ActionView::Template
而是一个 String
。知道为什么会这样吗?
问题二:
在大多数情况下,调用 rake cucumber
实际上会产生这样的结果:
stack level too deep (SystemStackError)
以前的开发人员确实将其作为 ActiveRecord::Base
的扩展:
module ActiveRecord
class Base
include Documentable
...
def self.has_url
include Rails.application.routes.url_helpers
self.default_url_options = Rails.application.default_url_options
define_method :url do
send "#{self.class.to_s.underscore}_url", self
end
end
end
end
当然,这可能是原因。我已经尝试通过 ActiveRecord::Concern
方法替换那个(相当过时的)扩展 ActiveRecord 的方法,遗憾的是这没有什么区别。我已经对这个项目进行了广泛的 grep,这是其中唯一一个真正像那样包含 Rails 模块的地方,所以现在应该是该错误的唯一候选者,对吗?
对于这两个问题,我都一头雾水。我在 Rails 方面有一些经验(~15 个项目)并且从来没有遇到过这样的一年级问题。
感谢您的关注。任何想法都会受到赞赏,即使我已经尝试过了。
更新#1:
根据要求,将 before_filter
粘贴到 ApplicationController
中。
def remove_oauth_params
params.reject! {|k,_| %w[oauth_token bearer_token access_token].include? k}
end
def save_action
@current_action = params[:action]
end
def set_access_header
if request.path == "/users/sign_out"
headers["Access-Control-Allow-Credentials"] = "true"
headers["Access-Control-Allow-Headers"] = %w{Origin Accept Content-Type X-Requested-With X-CSRF-Token X-File-Name X-File-Size Cache-Control}.join(",")
headers["Access-Control-Allow-Methods"] = "DELETE"
headers["Access-Control-Allow-Origin"] = "http://#{Settings.app_domain}"
else
headers["Access-Control-Allow-Origin"] = "*"
headers["Access-Control-Allow-Methods"] = %w{GET POST PUT DELETE PATCH}.join(",")
headers["Access-Control-Allow-Headers"] = %w{Origin Accept Content-Type X-Requested-With X-CSRF-Token X-File-Name X-File-Size Cache-Control}.join(",")
end
head(:ok) if request.request_method == "OPTIONS"
end
def set_limit_and_offset
@limit = params.delete(:limit).to_i
@limit = default_limit unless (1..default_limit).include?(@limit)
@offset = params.delete(:offset).to_i
@offset = 0 unless @offset > 0
end
至于 InvoiceController
,非常基础:
class InvoicesController < ApplicationController
oauthenticate :interactive => false
layout "invoice"
def preview
@i = Invoice.find(params[:id])
@origin = params[:origin]
end
end
更新#2:
$ rake cucumber --trace
** Invoke cucumber (first_time)
** Invoke cucumber:ok (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:test:purge
** Invoke environment
** Execute db:test:load
** Invoke db:test:load_schema (first_time)
** Invoke db:test:purge
** Execute db:test:load_schema
** Invoke db:schema:load (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:schema:load
** Invoke db:seed (first_time)
** Execute db:seed
** Invoke db:abort_if_pending_migrations
building users for ce and ce-int brands
building example CE app owner
building CE beta app
** Execute cucumber:ok
/usr/local/rvm/rubies/ruby-2.0.0-p353/bin/ruby -S bundle exec cucumber --profile default
Using the default profile...
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
Feature: Creation of robinson entries
Create a robinson entry to prevent recipients from being mailed
Background: # features/blocked_address/blocked_address_creation.feature:4
Given there is the example customer with id 200 # features/step_definitions/data_steps.rb:41
stack level too deep (SystemStackError)
features/blocked_address/blocked_address_creation.feature:5:in `Given there is the example customer with id 200'
最佳答案
编辑:参见 dimitkos comment寻求解决方案。
恐怕我没有简单的答案,只有两个调试建议:
对于问题1:
app.get "/me/invoices/22/preview?oauth_token=XE03DFCGyCDYjdu8oWuU9zrN56Z6Wr7eZDuIjCbT&origin=http://localhost:9294"
至于2:你用git做源码控制吗?
如果是,这是尝试 git bisect
的最佳时机。你找到了一个旧的提交,其中 rake cucumber
仍在工作,而 git 帮助你在非常少的步骤中找到破坏它的提交。更多信息:Debugging with Git - Binary search
关于ruby-on-rails - Rails 项目 : NoMethodError: undefined method `identifier' for String,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20452322/
更新:添加关于 Hashable 的相同错误 我已经创建了一个 Identifiable 兼容协议(protocol)和兼容结构。然后,当我创建列表并在 ForEach 中引用它时,我收到错误 Typ
这只是我偶然发现的例子! 我正在使用 cout与 operator // imports the declaration of std::cout using namespace std; // ma
我有一些表,我使用 MySQL Workbench 创建了 role_has_action 表。 创建的字段是:(role_id,action_id,action_controller_id): (为
我有一个 codesign 无法完全验证的应用程序,因为它“不满足其指定的要求”。第一次检查返回“在磁盘上有效”,所以没关系。 codesign -dvvvv -r- PATH_TO_APP 告诉我要
我正在使用 Java SDK 创建 SAS 来访问 blob。这是代码: SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy(); p
#include "stdafx.h" #include #include #include #include #include using namespace std; #define T
我在代码中看到了这两种方法。你能解释一下这两者有什么区别吗?正如我认为它与 C++ 完成命名空间查找的方式有关,您能否也提供一些相关信息,或者提供一个好的文档的链接?谢谢。 最佳答案 示例: #inc
我一直在使用一个工具 sbconstants从我的 Xcode 项目中的 Storyboard 标识符和重用标识符创建外部常量。 我已将包含这些常量的所有声明的 header #imported 到项
我想知道 bundle Identifier(在 info.plist 中)之间的区别。以及产品 Bundle Identifier(在 Build Setting -> Packaging -> P
我有课Identifier它本质上是 UUID 的类型安全包装器(因此类 Foo 包含 Identifier )。 FooStore类有一个方法 List> bulkReadIdentifiers()
在 Go 中,公共(public)名称以大写字母开头,私有(private)名称以小写字母开头。 我正在编写一个不是库的程序,它是一个单独的包。是否有任何 Go 习语规定我的标识符应该全部公开还是全部
我有一个页面 url,它看起来像: http://mydomain.com/nodes/32/article/new?return=view 安装 tomcat 7 后,尝试访问它时出现此异常: /n
我正在学习以下教程: http://www.appcoda.com/ios7-programming-ibeacons-tutorial/ 但是,我没有使用 iPhone 作为信标,而是使用制造商(R
我在为我的 iPhone 应用程序的下一版本上传 .app 文件时收到此错误“Bundle Identifier differents from prior bundle identifier”。 注
Scene 1, Layer 'script', Frame 1, Line 9 1084: Syntax error: expecting identifier before this. Sc
升级到 Xcode 7 后,我注意到 CFBundleIdentifier 已开始指向在 Build Settings/Packaging 中找到的产品捆绑标识符,而不是 Info.Plist 中的捆
关闭。这个问题需要debugging details .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 5年前关闭。 Improve this question 我在
我使用 Apache DBCP 来获取连接池,我每次都使用 PoolingDataSource 来获取连接。当我向数据库中插入一个对象时,它工作得很好,但是当我尝试从数据库中选择一个元素时,就会出现问
由于我项目的 react-native 版本 (0.44.3),我正在尝试在版本 0.6.4 中安装包 react-native-today-widget,我能够成功安装包: yarn add rea
之前有人问过这个问题,我已经查看了所有其他 stackoverflow 主题的答案,但我无法解决这个问题。 我的应用程序在所有平台的模拟器中运行良好,但是当我在我的设备上运行该应用程序时,我收到错误代
我是一名优秀的程序员,十分优秀!