0

启动我的 Rails 应用程序时,出现以下错误。有人可以提示我在哪里搜索错误吗?

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)
4

1 回答 1

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命令。

于 2012-08-29T17:59:40.830 回答