2012-09-13 2 views
2

여기 Heroku에서 호스트 할 캔버스 앱을 만드는 방법에 대한 Heroku의 자습서에서 코드를 복사하여 붙여 넣습니다. https://devcenter.heroku.com/articles/facebook-ruby 그러나 backtrace (아래 참조)가 omniauth와 관련되어 있다는 오류가 발생합니다.Heroku의 Facebook 캔버스 앱 튜토리얼 : 선서 오류

사람이 설명 할 수

NoMethodError at/
undefined method `include?' for nil:NilClass 
file: builder.rb location: call line: 29 

이들 보석은이

gem 'sinatra', '1.0' 
gem 'oa-oauth', '0.1.6' 



BACKTRACE 
(condense) 
JUMP TO: GET POST COOKIES ENV 
/Users/michael/.rvm/gems/[email protected]/gems/oa-core-0.1.6/lib/omniauth/builder.rb in call 
     @ins << @app unless @ins.include?(@app) 
/Users/michael/.rvm/gems/[email protected]/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb in call 
     status, headers, body = @app.call(env) 
/Users/michael/.rvm/gems/[email protected]/gems/rack-protection-1.2.0/lib/rack/protection/base.rb in call 
     result or app.call(env) 
/Users/michael/.rvm/gems/[email protected]/gems/rack-protection-1.2.0/lib/rack/protection/base.rb in call 
     result or app.call(env) 
/Users/michael/.rvm/gems/[email protected]/gems/rack-protection-1.2.0/lib/rack/protection/path_traversal.rb in call 

홈페이지 코드를 사용

index.erb

<%=session['fb_error']%> 

<% if session['fb_auth'] %> 
    <a href='logout'><img src='images/fb_logout_button.png'></a> 
<% else %> 
    <a href='auth/facebook'><img src='images/fb_login_button.png'></a> 
<% end %> 

<h3><%= 'Hello, ' + session['fb_auth']['user_info']['first_name'] + ', ' if session['fb_token'] %>Welcome to my list of interesting articles.</h3> 

<table> 
    <% @articles.each do |article| %> 
    <tr> 
    <td class='article'>- <a href='<%=article[:url]%>' target='_blank'><%=article[:title]%></a></td> 
    <td> 
     <% if session['fb_auth'] %> 
     <iframe src="http://www.facebook.com/plugins/like.php?href=<%=article[:url]%>&amp;layout=button_count&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px;" allowTransparency="true"></iframe> 
     <% end %> 
    </td> 
    </tr> 
    <% end %> 
</table> 

<% if session['fb_auth'] %> 
    <hr /> 
    <p><span class='like_site'>Do you like this site?</span></p> 
    <p><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Ffaceboku.heroku.com%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe></p> 
<% end %> 

Faceboku.rb

equire 'sinatra' 
require 'omniauth/oauth' 

enable :sessions 


#Here you have to put your own Application ID and Secret 
APP_ID = "495940167082961" 
APP_SECRET = "686da25c0fdd04a6f61b287bb0d5c9aa" 

use OmniAuth::Builder do 
    provider :facebook, APP_ID, APP_SECRET, { :scope => 'email, status_update, publish_stream' } 
end 

get '/' do 
    @articles = [] 
    @articles << {:title => 'Deploying Rack-based apps in Heroku', :url => 'http://docs.heroku.com/rack'} 
    @articles << {:title => 'Learn Ruby in twenty minutes', :url => 'http://www.ruby-lang.org/en/documentation/quickstart/'} 

    erb :index 
end 

get '/auth/facebook/callback' do 
    session['fb_auth'] = request.env['omniauth.auth'] 
    session['fb_token'] = session['fb_auth']['credentials']['token'] 
    session['fb_error'] = nil 
    redirect '/' 
end 

get '/auth/failure' do 
    clear_session 
    session['fb_error'] = 'In order to use this site you must allow us access to your Facebook data<br />' 
    redirect '/' 
end 

get '/logout' do 
    clear_session 
    redirect '/' 
end 

def clear_session 
    session['fb_auth'] = nil 
    session['fb_token'] = nil 
    session['fb_error'] = nil 
end 
+0

당 대답은 물론 자습서를 따라하고 있는데 얻을 수 없다 그것은 작동합니다. 번들러가 옴니아 우스 보석을 찾는 데 어려움을 겪고있는 것 같습니다. –

+0

Omniauth의 빌더 클래스가 환경 변수 일 수있는 @ins 변수에 질식하는 것으로 보입니다. –

+0

이봐, 얘들 아, 그 튜토리얼을 썼는데, 나는 그것을 검토하고 그것을 업데이트 할 시간이 없었다. 그러나 나는 곧 그것을 할 것이다. 잠시 기다려라. 나는이 소식이 업데이트 될 때 알려주도록하겠습니다. 감사! – raf

답변

1

은 "답변이없는"필터에서이 문제를 제거하기 위해 의견에서 답을 복사 :

는 얘들 아, 내가 튜토리얼 ... 내가했습니다 썼다 tuto와 코드를 업데이트했습니다. 모든 것이 지금 작동하고있는 것 같습니다. 제발, 그렇지 않으면 알려주세요. 내가 Heroku가의 승인을 기다릴 필요가 있지만, 어쨌든 작동하기 때문에 그것은 일부 이미지가 표시되지 않습니다 : https://devcenter.heroku.com/articles/facebook-ruby

~, 난이 2nding raf