被称为nil的id

时间:2012-10-28 08:52:44

标签: ruby-on-rails mongodb shapado

我正在尝试在我的OS X机器上安装Shapado。最终我想在Heroku上安装它,所以如果有人有安装指南,请告诉我。

我相信家属都没关系,mongodb正在运行。我跑的时候出错:

$rake bootstrap RAILS_ENV=development

rake aborted!
Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id


Seans-MacBook-Pro:shapado sean$ rake bootstrap RAILS_ENV=development
/Users/sean/.rvm/gems/ruby-1.9.3-p194/gems/maruku-0.6.0/lib/maruku/input/parse_doc.rb:22:in `<top (required)>': iconv will be deprecated in the future, use String#encode instead.
Loaded
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /Users/sean/Dropbox/rails/shapado/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /Users/sean/Dropbox/rails/shapado/Rakefile:7)
Missing GeoIP data. Please run '/Users/sean/Dropbox/rails/shapado/script/update_geoip'
>> Setting up Twitter provider
>> Setting up Facebook provider
>> Setting up Identica provider
>> Setting up Github provider
>> Setting up LinkedIn provider
rake aborted!
Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id

Tasks: TOP => bootstrap => setup:default_group
(See full trace by running task with --trace)
Seans-MacBook-Pro:shapado sean$ rake bootstrap RAILS_ENV=development
/Users/sean/.rvm/gems/ruby-1.9.3-p194/gems/maruku-0.6.0/lib/maruku/input/parse_doc.rb:22:in `<top (required)>': iconv will be deprecated in the future, use String#encode instead.
Loaded
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /Users/sean/Dropbox/rails/shapado/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /Users/sean/Dropbox/rails/shapado/Rakefile:7)
Missing GeoIP data. Please run '/Users/sean/Dropbox/rails/shapado/script/update_geoip'
>> Setting up Twitter provider
>> Setting up Facebook provider
>> Setting up Identica provider
>> Setting up Github provider
>> Setting up LinkedIn provider
rake aborted!
Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id

修改 从rake上的--trace标志输出

Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil,  use object_id
/Users/sean/Dropbox/rails/shapado/app/models/group.rb:641:in `set_shapado_version'

问题代码是:

def set_shapado_version
  self.shapado_version_id = ShapadoVersion.where(:token => 'free').first.id
end

3 个答案:

答案 0 :(得分:3)

app / models / group.rb中的

更改

def set_shapado_version
  self.shapado_version_id = ShapadoVersion.where(:token => 'free').first.id
end

def set_shapado_version
  self.shapado_version_id = ShapadoVersion.where(:token => 'free').first.try(:id)
end

以下是相关的合并请求:https://gitorious.org/shapado/shapado/merge_requests/18

答案 1 :(得分:1)

def set_shapado_version
  self.shapado_version_id = ShapadoVersion.where(:token => 'free').first.id
end

你确定有一个ShapadoVersion,其中token ='free'吗?我认为Rails抱怨这个问题。

答案 2 :(得分:0)

使用这篇文章:http://shapado.com/questions/rake-bootstrap-error-called-id-for-nil 通过执行以下操作,我设法通过 rake bootstrap

将shapado.yml中的第13行更改为 true

is_shapadocom: true

在config / payments.yml

中添加了以下内容
secret: vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE

添加了以下代码hack。原始行已注释。可能不是最好的方法。

def self.reload!
  #return unless AppConfig.is_shapadocom
  unless AppConfig.is_shapadocom
    ShapadoVersion.new(token: "free", price: 0).save!
    return
  end
  .
  .
  .

如果有人知道Shapado,请查看我的个人资料并与我联系。我有兴趣分享经验,尤其是推送Heroku。它看起来像一个很好的应用程序,但我找不到很多文档。