黄瓜和奶酪无法在当地运行小狗app

时间:2015-09-17 22:44:26

标签: ruby-on-rails ruby page-object-gem

贯穿杰夫摩根:黄瓜和奶酪,一切正常,直到我到达CH6数据库。 去了cheezyworld,下载并解压缩app。

8300:~/cheezy2/puppies$ bundle install
Fetching gem metadata from http://rubygems.org/...........
Fetching version metadata from http://rubygems.org/...
Fetching dependency metadata from http://rubygems.org/..
Could not find addressable-2.3.1 in any of the sources

我搜索并通过另一个版本的可解决的2.3.1错误,但这导致了更多的问题。我的下一步是转到github获取最新的小狗应用程序github cheezy小狗,我已经尝试了下载zip和克隆。

我的环境:(注意,我刚刚开始使用Ruby等人)

  • Ubuntu 14.04

  • Rubymine IDE,这是一个命令行问题

  • /home/userid/.rvm/gems显示ruby-1.9.3.p194,ruby-2.0.0-p643,ruby-2.1.2和ruby-2.2.2

问题:

  1. 我应该使用github最新版本还是cheezyworld 版本
  2. 我应该采取什么行动让小狗应用程序在本地运行并解决错误:找不到表小狗
  3. 如何处理所有rvm错误和/或警告?
  4. 谢谢 - 详情如下

    拉开dir并打开它后,我得到了:

    8300:~/cheezy$ cd puppies
    You are using '.rvmrc', it requires trusting, it is slower and it is not 
    compatible with other ruby managers,
    you can switch to '.ruby-version' using 'rvm rvmrc to ruby-version'
    or ignore this warning with 
    'rvm rvmrc warning ignore /home/user/cheezy/puppies/.rvmrc',
    '.rvmrc' will continue to be the default project 
    file in RVM 1 and RVM 2,
    to ignore the warning for all files run 'rvm rvmrc warning 
    ignore all.rvmrcs'.
    

    我搜索并发现我应该这样做:

    8300:~/cheezy/puppies$ rvm rvmrc warning ignore all.rvmrcs
    8300:~/cheezy/puppies$ bundle install
    

    然后我做了rails s

    8300:~/cheezy/puppies$ rails s
    => Booting WEBrick
    => Rails 3.2.11 application starting in development on http://0.0.0.0:3000
    => Call with -d to detach
    => Ctrl-C to shutdown server
    [2015-09-17 14:31:26] INFO  WEBrick 1.3.1
    [2015-09-17 14:31:26] INFO  ruby 1.9.3 (2012-04-20) [x86_64-linux]
    [2015-09-17 14:31:26] INFO  WEBrick::HTTPServer#start: pid=26994 port=3000
    

    根据这本书,以上是正确的。但是,当我转到网址时     本地主机:3000

    我在控制台看到错误:

    Started GET "/" for 127.0.0.1 at 2015-09-17 14:31:59 -0700
    Connecting to database specified by database.yml
    Processing by AgencyController#index as HTML
      Rendered agency/index.html.erb within layouts/application (19.8ms)
    Completed 500 Internal Server Error in 43ms
    
    ActionView::Template::Error (Could not find table 'puppies'):
        4: 
        5: <h1>Puppy List</h1>
        6: 
        7: <% @puppies.each do |puppy| -%>
        8:   <div class="puppy_list">
        9:     <div class='<%= cycle('list_line_odd', 'list_line_even') %>'>
        10:       <div class="image"><%= image_tag(puppy.image_url, :class => 'list_image') %></div>
      app/views/agency/index.html.erb:7:in `_app_views_agency_index_html_erb___380271329036758088_31446620'
    
    
      Rendered /home/user/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.0ms)
      Rendered /home/user/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.7ms)
      Rendered /home/user/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (5.6ms)
    

    在浏览器中我收到错误页面

    ActiveRecord::StatementInvalid in Agency#index
    Showing /home/user/cheezy/puppies/app/views/agency/index.html.erb where line #7 raised:
    Could not find table 'puppies'
    

    我跑了rvm list:

    :~/.rvm/gems$ rvm list
    Warning! PATH is not properly set up, '/home/userid/.rvm/gems/ruby-2.2.2/bin' is not at first place,
         usually this is caused by shell initialization files - check them for 'PATH=...' entries,
         it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
         to fix temporarily in this shell session run: 'rvm use ruby-2.2.2'.
    
    rvm rubies
    
       ruby-1.9.3-p194 [ x86_64 ]
       ruby-2.0.0-p643 [ x86_64 ]
       ruby-2.1.2 [ x86_64 ]
       ruby-2.2.1 [ x86_64 ]
    =* ruby-2.2.2 [ x86_64 ]
    
    # => - current
    # =* - current && default
    #  * - default
    

1 个答案:

答案 0 :(得分:1)

如果您正在关注黄瓜和奶酪书:

  • 转到github puppies并克隆项目
  • 当你cd到小狗目录时,你可能会看到关于“信任”的警告,运行命令:rvm rvmrc trust~ / your-path / puppies /
  • 你可能想要运行:rvm list#to ck ruby​​ version for project
  • 您可以运行:cat .rvmrc#以查看项目所需的版本
  • 确保.rvmrc中的ruby版本与rvm list中的“当前”版本匹配
  • 阅读整个自述文件,了解最新的说明,例如: rake db:seed,rake db:migrate,在运行之前按照这些操作:rails s