class TwitterProfile < ActiveRecord::Base
def send_status_update(status_update)
if publish?
client = Twitter::Client.new(:oauth_token => authentication.token,
:oauth_token_secret => authentication.secret)
client.update(status_update.to_twitter_string)
end
rescue Exception => e
logger.info "Error publishing to twitter: #{e.to_s}"
end
end
StatusUpdate 모델 after_create
트위터로 재 게시 관찰자가 정의되지.루비 나가서 설명하자면 NameError 로컬 변수 또는 방법 E '
NameError (undefined local variable or method `e' for #<TwitterProfile:0x00000004e44ab8>):
app/models/twitter_profile.rb:23:in `rescue in send_status_update'
app/models/twitter_profile.rb:18:in `send_status_update'
app/models/status_update_observer.rb:6:in `block in after_create'
app/models/status_update_observer.rb:4:in `after_create'
app/models/workout_observer.rb:5:in `after_update'
app/controllers/frames_controller.rb:76:in `update'
app/controllers/application_controller.rb:24:in `call'
app/controllers/application_controller.rb:24:in `block (2 levels) in <class:ApplicationController>'
app/controllers/application_controller.rb:10:in `block in <class:ApplicationController>'
나는 여기에 놓치고 무엇 : I 가끔 다음과 같은 예외가?
이상하지만 흥미 롭습니다.'=> e'가없는 것처럼 보입니다. –
참고 :'Exception'을 구출하지 말고 대신'StandardError'를 구하십시오. http://www.thattommyhall.com/2011/02/24/rescue-exception-harmful-signals-in-ruby/ – zetetic