2012-04-26 66 views
1

我是Shapado的新手。我想在我的筆記本電腦(MAC OS)安裝shapado,當我嘗試訪問http://localhost.lan:3000我有以下錯誤:在Shapado中的問題#索引中的錯誤NoMethodError(Ruby on Rails)

NoMethodError in Questions#index 

Showing /Users/sciruela/Documents/shapado/shapado/app/views/shared/_login_drop_down.html.haml where line #10 raised: 

undefined method `[]' for nil:NilClass 
Extracted source (around line #10): 

7:   = link_to provider.titleize, '/users/auth/facebook', :class => 'auth-provider Facebook', :id => 'facebook' 
8:  - else 
9:  %li 
10:   = link_to provider.titleize, multiauth_url(provider), :class => "auth-provider #{provider}", :id => dprovider 
11: 
12: -if current_group.allow_any_openid 
13:  %li 
Trace of template inclusion: app/views/shared/_login_menu.html.haml, app/views/shared/_topbar.html.haml, app/views/layouts/application.html.haml 

Rails.root: /Users/sciruela/Documents/shapado/shapado 

Application Trace | Framework Trace | Full Trace 
app/views/shared/_login_drop_down.html.haml:10:in `block in _app_views_shared__login_drop_down_html_haml__1123238317393261506_2159776840' 
app/views/shared/_login_drop_down.html.haml:2:in `each' 
app/views/shared/_login_drop_down.html.haml:2:in `_app_views_shared__login_drop_down_html_haml__1123238317393261506_2159776840' 
app/views/shared/_login_menu.html.haml:6:in `_app_views_shared__login_menu_html_haml___434956048083202339_2193663100' 
app/helpers/application_helper.rb:36:in `multiauth_dropdown' 
app/views/shared/_topbar.html.haml:21:in `_app_views_shared__topbar_html_haml___2782218627514502243_2204427320' 
app/views/layouts/application.html.haml:10:in `block in _app_views_layouts_application_html_haml___4514694021451724572_2205033860' 
app/helpers/layout_helper.rb:74:in `call' 
app/helpers/layout_helper.rb:74:in `block in ie_tag' 
app/helpers/layout_helper.rb:72:in `ie_tag' 
app/helpers/layout_helper.rb:79:in `ie_html' 
app/views/layouts/application.html.haml:2:in `_app_views_layouts_application_html_haml___4514694021451724572_2205033860' 
app/controllers/application_controller.rb:122:in `block (2 levels) in find_questions' 
app/controllers/application_controller.rb:121:in `find_questions' 
app/controllers/questions_controller.rb:67:in `index' 
lib/sso_strategy.rb:18:in `call!' 
app/middlewares/dynamic_domain.rb:17:in `call' 
Request 

我怎麼能解決呢?

由於

回答

2

在Rails中,[]用作讀取器和[]=作爲設定器。它看起來像在multiauth_url(provider)的第10行發生的問題。

在這種情況下,看起來供應商也是nil。我建議使用pry(一顆寶石)並放入binding.pry進一步調試。您可能會假定提供者總是存在,因此首先驗證提供者不是nil