小编Eri*_*icM的帖子

Hartl Rails第8.3节rspec错误

我正在通过hartl rails教程

我在8.3节的末尾,应用程序运行正常,但我收到了一个rspec错误

1) User pages signup with valid information after saving the user 
 Failure/Error: it { should have_link('Sign out') }
   expected link "Sign out" to return something
 # ./spec/requests/user_pages_spec.rb:48:in `block (5 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)

user_pages_spec.rb中涉及的部分是

it "should create a user" do
    expect { click_button submit }.to change(User, :count).by(1)
  end  
  describe "after saving the user" do
    it { should have_link('Sign out') }
  end
Run Code Online (Sandbox Code Playgroud)

关于如何解决这个问题,我有点不知所措.还有其他类似的帖子,但唉,我不能让他们的解决方案在我的情况下工作.谢谢.

ruby-on-rails-3 railstutorial.org

3
推荐指数
1
解决办法
406
查看次数

这些错误消息是什么意思?

我在hartl rails教程的第9节中,这个def没有意义.想法?

1) User pages index 
 Failure/Error: visit users_path
 ActionView::Template::Error:
   wrong number of arguments (2 for 1)
 # ./app/helpers/users_helper.rb:3:in `gravatar_for'
 # ./app/views/users/index.html.erb:7:in `block in _app_views_users_index_html_erb__3004047397113020476_70255017945740'
 # ./app/views/users/index.html.erb:5:in `each'
 # ./app/views/users/index.html.erb:5:in `_app_views_users_index_html_erb__3004047397113020476_70255017945740'
 # ./spec/requests/user_pages_spec.rb:12:in `block (3 levels) in <top (required)>'



2) User pages index should list each user
 Failure/Error: visit users_path
 ActionView::Template::Error:
   wrong number of arguments (2 for 1)
 # ./app/helpers/users_helper.rb:3:in `gravatar_for'
 # ./app/views/users/index.html.erb:7:in `block in _app_views_users_index_html_erb__3004047397113020476_70255017945740'
 # ./app/views/users/index.html.erb:5:in `each'
 # ./app/views/users/index.html.erb:5:in `_app_views_users_index_html_erb__3004047397113020476_70255017945740'
 # ./spec/requests/user_pages_spec.rb:12:in `block (3 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails ruby-on-rails-3 railstutorial.org

3
推荐指数
1
解决办法
1581
查看次数

教我自己将第一个应用程序部署到heroku -failure上传 - sqlite3和postgregitch

我教自己铁路.我是程序员但不是网络程序员.我在这里浏览Michael Hartl的书

它提到从一开始就开始部署应用程序是一个好主意.我同意.所以我在Heroku上获得了一个帐户并经历了设置等.然后创建了我的第一个应用程序,git和工程.然后按照Heroku网站上的所有说明进行操作.最后,我使用此命令将我的应用程序推送到Heroku:

git push heroku master
Run Code Online (Sandbox Code Playgroud)

这本书说在这个阶段可能会出现问题,因为我的机器上的应用程序使用的是sqlite3而Heroku需要postgresql.这本书建议改变我的应用程序的gem文件中的一行

gem 'sqlite3'
Run Code Online (Sandbox Code Playgroud)

gem 'sqlite3-ruby', :group => :development
Run Code Online (Sandbox Code Playgroud)

我尝试了然后运行bundle install然后尝试推送应用程序.没有运气我在我的控制台上收到此消息:

An error occured while installing sqlite3 (1.3.6), and Bundler cannot continue.
   Make sure that `gem install sqlite3 -v '1.3.6'` succeeds before bundling.
Run Code Online (Sandbox Code Playgroud)

!!无法通过Bundler安装gem.!!Heroku推送拒绝,无法编译Ruby/rails应用程序

所以我尝试了Heroku网站在这里建议的内容

改变我的宝石文件

由此:

gem 'sqlite3'
Run Code Online (Sandbox Code Playgroud)

对此:

gem 'pg'
Run Code Online (Sandbox Code Playgroud)

所以我尝试了这种方法然后运行'捆绑安装'.但这也不起作用.我在控制台上收到此消息:

Installing pg (0.13.2) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/AM/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 
checking for pg_config... no
No pg_config... trying anyway. If building …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails heroku railstutorial.org gemfile

2
推荐指数
1
解决办法
3856
查看次数