2012-08-29 85 views
0

当启动我的rails应用程序时,出现以下错误。有人可以给我一个暗示在哪里寻找错误?未定义的方法table_alias

undefined method `table_alias' for #<ActiveRecord::Relation:0x0000000339df20> 

这是我Gemfile.lock的

GEM 
    remote: http://rubygems.org/ 
    specs: 
    abstract (1.0.0) 
    actionmailer (3.0.12) 
     actionpack (= 3.0.12) 
     mail (~> 2.2.19) 
    actionpack (3.0.12) 
     activemodel (= 3.0.12) 
     activesupport (= 3.0.12) 
     builder (~> 2.1.2) 
     erubis (~> 2.6.6) 
     i18n (~> 0.5.0) 
     rack (~> 1.2.5) 
     rack-mount (~> 0.6.14) 
     rack-test (~> 0.5.7) 
     tzinfo (~> 0.3.23) 
    activemodel (3.0.12) 
     activesupport (= 3.0.12) 
     builder (~> 2.1.2) 
     i18n (~> 0.5.0) 
    activerecord (3.0.12) 
     activemodel (= 3.0.12) 
     activesupport (= 3.0.12) 
     arel (~> 2.0.10) 
     tzinfo (~> 0.3.23) 
    activerecord-mysql2-adapter (0.0.3) 
     mysql2 
    activeresource (3.0.12) 
     activemodel (= 3.0.12) 
     activesupport (= 3.0.12) 
    activesupport (3.0.12) 
    antlr3 (1.8.12) 
    arel (2.0.10) 
    builder (2.1.2) 
    composite_primary_keys (3.0.0.b3) 
     activerecord (>= 3.0.1) 
    erubis (2.6.6) 
     abstract (>= 1.0.0) 
    fast_xs (0.8.0) 
    i18n (0.5.0) 
    in_place_editing (1.2.0) 
    jquery-rails (1.0.19) 
     railties (~> 3.0) 
     thor (~> 0.14) 
    json (1.7.5) 
    libxml-ruby (2.3.3) 
    mail (2.2.19) 
     activesupport (>= 2.3.6) 
     i18n (>= 0.4.0) 
     mime-types (~> 1.16) 
     treetop (~> 1.4.8) 
    mime-types (1.19) 
    mysql (2.8.1) 
    mysql2 (0.3.11) 
    net-sftp (2.0.5) 
     net-ssh (>= 2.0.9) 
    net-ssh (2.5.2) 
    newrelic_rpm (3.4.1) 
    nokogiri (1.5.5) 
    polyglot (0.3.3) 
    rack (1.2.5) 
    rack-mount (0.6.14) 
     rack (>= 1.0.0) 
    rack-test (0.5.7) 
     rack (>= 1.0) 
    rails (3.0.12) 
     actionmailer (= 3.0.12) 
     actionpack (= 3.0.12) 
     activerecord (= 3.0.12) 
     activeresource (= 3.0.12) 
     activesupport (= 3.0.12) 
     bundler (~> 1.0) 
     railties (= 3.0.12) 
    railties (3.0.12) 
     actionpack (= 3.0.12) 
     activesupport (= 3.0.12) 
     rake (>= 0.8.7) 
     rdoc (~> 3.4) 
     thor (~> 0.14.4) 
    rake (0.9.2.2) 
    rdoc (3.12) 
     json (~> 1.4) 
    ruby-ole (1.2.11.4) 
    rubyzip (0.9.9) 
    simple_xlsx_writer (0.5.3) 
     fast_xs (>= 0.7.3) 
     rubyzip (>= 0.9.4) 
    spreadsheet (0.7.3) 
     ruby-ole (>= 1.0) 
    surpass (0.1.0) 
    thor (0.14.6) 
    treetop (1.4.10) 
     polyglot 
     polyglot (>= 0.3.1) 
    tzinfo (0.3.33) 
    will_paginate (3.0.3) 
    xsd_xml_parser (0.0.4) 
     nokogiri (>= 1.5.0) 

PLATFORMS 
    ruby 

DEPENDENCIES 
    activerecord-mysql2-adapter 
    antlr3 
    composite_primary_keys (= 3.0.0.b3) 
    in_place_editing 
    jquery-rails 
    json 
    libxml-ruby 
    mysql 
    mysql2 
    net-sftp 
    net-ssh 
    newrelic_rpm 
    nokogiri 
    rails (= 3.0.12) 
    rubyzip 
    simple_xlsx_writer 
    spreadsheet 
    surpass 
    will_paginate 
    xsd_xml_parser (= 0.0.4) 
+0

该错误在哪里发生?文件/行号。我相信Gemfile.lock在这里没有任何关系。你正试图为没有它的对象调用方法'table_alias'。 – Nobita

回答

0

首先需要检查的是 - 你调用一个方法table_alias地方?也许你忘了定义函数尝试这种在项目目录:

find . -type f | xargs grep "table_alias" 

这会找到任何文件的方法在你的项目结构 - 如果它的存在。

想到另一种可能性,因为这是ActiveRecord,你还没有初始化你的数据库......你运行了rake db命令吗?例如,我们使用ActiveRecord的会话存储,所以初始化看起来是这样的:

bundle exec rake db:create:sessions 
bundle exec rake db:migrate 

还有一个rake db:setup命令。

+0

我没有叫这个方法,看起来像我使用的宝石,叫它,所以更新所有的宝石似乎解决了这个问题... –