최근에 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
보시 다시피이 단어 는 컨트롤러 작업의 이름입니다.
NewRelic을 제거해도 도움이되지 않습니다. 그런 다음 오류는 다음으로 대체됩니다.
NoMethodError (undefined method `formats' for "preview":String):
BTW, 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
. 왜 그럴까요?
문제 2 :
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를 확장하기 위해 (아주 쓸모없는) 방법을 대체하려고 시도했지만 ActiveRecord::Concern
슬프게도 아무런 차이가 없습니다. 나는 이미 프로젝트를 상당히 광범위하게 grep했다. 그것은 Rails 모듈이 실제로 그렇게 포함 된 유일한 곳이다. 그래서 지금 그 오류에 대한 유일한 후보가되어야한다.
이 두 가지 문제에 대해 저는 완전히 손실을 입었습니다. 저는 Rails (~ 15 개 프로젝트)에서 일종의 경험을했고 그런 1 학년 문제가 없었습니다.
주목 해 주셔서 감사합니다. 이미 시도 했더라도 어떤 아이디어라도 감사하겠습니다.
업데이트 # 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 주석 을 참조하십시오 .
쉬운 대답은 없지만 두 가지 디버깅 제안 만 있습니다.
문제 1 :
app.get "/me/invoices/22/preview?oauth_token=XE03DFCGyCDYjdu8oWuU9zrN56Z6Wr7eZDuIjCbT&origin=http://localhost:9294"
2 : 소스 제어에 git을 사용합니까?
그렇다면 지금은 사용해보기에 완벽한 순간 git bisect
입니다. rake cucumber
여전히 작동 하는 오래된 커밋 을 찾고 git은 몇 단계 만에 커밋을 깨뜨린 커밋을 찾는 데 도움을줍니다. 더보기 : Git으로 디버깅-이진 검색
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다