Shapado中的问题#index中的错误NoMethodError(Ruby on Rails)

时间:2012-04-26 11:45:55

标签: ruby-on-rails shapado

我是Shapado的新手。我正在尝试在我的笔记本电脑(MAC OS)中安装shapado,当我尝试访问http://localhost.lan:3000时出现以下错误:

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 个答案:

答案 0 :(得分:2)

在Rails中,[]充当读者,[]=充当设定者。看起来问题发生在multiauth_url(provider)的第10行。

在这种情况下,提供商似乎也是nil。我建议使用pry(一个宝石)并放入binding.pry进一步调试。您可能假设提供程序始终存在,因此请首先验证提供程序不是nil

答案 1 :(得分:1)

你是否关注过shapado的自述文件?好像你没有这一步 https://github.com/ricodigo/shapado/blob/master/README#L25