Reputation: 3134
Comment on the downvoting: This question has erroneously been marked as duplicate. It is clear from the gemfile which I have attached that I am using a more recent version of bcrypt. This and other differences (I am using Ubuntu 12.04 whereas the other thread mentions Windows) makes the solution of that other thread inapplicable to my case. I am still having the issue and would welcome any advice.
=end of comment
I'm working through the famous Rails tutorial but got stuck at Listing 7.5 - I think I followed all instructions but instead of getting I'm getting . The actual error stack is:
app/models/user.rb:6:in `<class:User>'
app/models/user.rb:1:in `<top (required)>'
app/controllers/users_controller.rb:4:in `show'
This error occurred while loading the following files:
bcrypt
Request
Parameters:
{"id"=>"1"}
Here is my Gemfile:
source 'https://rubygems.org'
ruby '2.1.1'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.4'
gem 'bootstrap-sass', '2.3.2.0'
gem 'sprockets', '2.11.0'
gem 'bcrypt-ruby', '3.1.2'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
gem 'guard-rspec', '2.5.0'
gem 'spork-rails', '4.0.0'
gem 'guard-spork', '1.5.0'
gem 'childprocess', '0.3.6'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
Here is the User.rb:
class User < ActiveRecord::Base
before_save {self.email = email.downcase}
validates :name, presence: true, length: { maximum: 50 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: { case_sensitive: false }
has_secure_password
validates :password, length: { minimum: 6 }
end
Here is the routes.rb:
SampleApp::Application.routes.draw do
resources :users # replaces: get "users/new"
root 'static_pages#home'
match '/signup', to: 'users#new', via: 'get'
match '/help', to: 'static_pages#help', via: 'get'
match '/about', to: 'static_pages#about', via: 'get'
match '/contact', to: 'static_pages#contact', via: 'get'
end
And here is the user_controller.rb:
class UsersController < ApplicationController
def show
@user = User.find(params[:id])
end
def new
end
end
Can you tell where is the problem?
Upvotes: 4
Views: 5016
Reputation: 41
It was the WEBrick restart which fixed your problem. The rails console output would have been displaying the error:
You don't have bcrypt installed in your application. Please add it to your Gemfile and run bundle install
Completed 500 Internal Server Error in 10ms
LoadError (cannot load such file -- bcrypt):
This was caused because after installing the bcrypt gem for "A Hashed Password" (section 6.3.1 in the tutorial) there is no explicit instruction to restart the server.
Upvotes: 4
Reputation: 3134
Curiuosly, restarting the WEBrick server eliminated the problem. This was done after a system re-boot preceded by a partial upgrade of the system (Ubuntu 12.04) as response to an unrelated issue (the Heartbleed bug) so I don't really know whether it was just the WEBrick restart which eliminated the problem.
Upvotes: 9