在另一台机器上设置Ruby On Rails项目的问题

时间:2014-05-02 09:26:35

标签: ruby-on-rails ruby postgresql

我在另一台机器(Mac OS X)上设置了一个现有ruby on rails项目我已经设置了源文件然后安装了bundler,之后通过运行'bundle install'安装了所需的gem。 为了设置数据库,我创建了database.yml,系统使用postgres进行数据库。然后我使用转储文件导入所有数据。 现在,当我运行rails服务器并点击localhost:3000时,我收到以下错误

 PG::Error: ERROR:  relation "wp_posts" does not exist
LINE 4:              WHERE a.attrelid = '"wp_posts"'::regclass
                                        ^
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = '"wp_posts"'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum
Completed 500 Internal Server Error in 1626ms

ActionView::Template::Error (PG::Error: ERROR:  relation "wp_posts" does not exist
LINE 4:              WHERE a.attrelid = '"wp_posts"'::regclass
                                        ^
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = '"wp_posts"'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum
):
    149:                            </li>
    150:                                <li>
    151:                                    <h2>Sunridge RV Blog</h2>
    152:                   <% if wp_post.present? %>
    153:                     <h3>Most Recent Post:</h3>
    154:                     <p><%=link_to wp_post.post_title, "/blog/#{wp_post.post_name}", :target => "_blank"%></p>
    155:                   <% end %>
  app/controllers/application_controller.rb:82:in `wp_post'
  app/views/layouts/application.html.erb:152:in `_app_views_layouts_application_html_erb__949835775984651851_2180765060'

我还执行了'rake db:migrate'但没有发生任何事情。

1 个答案:

答案 0 :(得分:0)

在您的database.yml中,可以验证您是否为您尝试运行该应用程序的相应环境指定了正确的适配器?它应该类似于以下内容(postgres的完全限定的database.yml条目):

development:
    adapter: postgresql
    database: <project>_development
    host: localhost
    username: user
    password:
    pool: 5
    timeout: 5000
    port: 5432