質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails 4

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

Q&A

解決済

1回答

175閲覧

ルビーレイルズの会員登録機能作成の際に出る cannot load such file -- bcrypt という errorの直し方

rura

総合スコア70

Ruby on Rails 4

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

0グッド

0クリップ

投稿2018/02/01 11:28

前提・実現したいこと

ルビーオンレイルズのジェムファイルの(gem 'bcrypt', '~> 3.1.7')を使用して、
会員登録機能を実装してますが、
うまくいきません。
どなたか解決策わかる方いましたら、
お願いします。

発生している問題・エラーメッセージ

LoadError in UsersController#index cannot load such file -- bcrypt Extracted source (around line #4): 2 3 4 5 6 7 before_save { email.downcase! } has_secure_password def self.new_remember_token SecureRandom.urlsafe_base64 Rails.root: /home/ubuntu/workspace/enjin Application Trace | Framework Trace | Full Trace app/models/user.rb:4:in `<class:User>' app/models/user.rb:1:in `<top (required)>' app/controllers/users_controller.rb:6:in `index' This error occurred while loading the following files: bcrypt Request Parameters: None Toggle session dump Toggle env dump Response Headers: None

該当のソースコード

user.rb

class User < ActiveRecord::Base before_save { email.downcase! } has_secure_password def self.new_remember_token SecureRandom.urlsafe_base64 end def self.encrypt(token) Digest::SHA1.hexdigest(token.to_s) end end

試したこと

https://qiita.com/totto357/items/1741da83bf642dab99df
こちらを参考に解決を試みましたが
だめでした。

補足情報(FW/ツールのバージョンなど)

Ruby、cloud9, git hub

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

$ bundle install はしてあります???
bcryptがインストールされていないように見えますが...

投稿2018/02/01 11:35

h_daido

総合スコア824

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

rura

2018/02/01 11:39

現在のわがジェムファイルです。 source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.10' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.1.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.0' # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', '~> 0.4.0', group: :doc # Use ActiveModel has_secure_password gem 'bcrypt', '~> 3.1.7' # Use Unicorn as the app server # gem 'unicorn' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' end group :development do # Access an IRB console on exception pages or by using <%= console %> in views gem 'web-console', '~> 2.0' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' end
h_daido

2018/02/01 11:45

gemfileに記載しただけだとinstallされないですよ。bundle installしないと
rura

2018/02/01 12:11

もっかい、bundle installを掛けてみます。
rura

2018/02/01 12:40

あ!行けました。ありがとうございます。 ジェムファイルに記述しただから、SERVER君がよみこんでないよと怒ってたということですね。 はい。
rura

2018/02/01 13:56

作業としては下記の通りでした。 ジェムにgem 'bcrypt', '~> 3.1.7' を記入追加 bundle install コマンドを入力 レイルズSERVERのシャットダウン → sudo service apache2 stop をサーバーにコマンド入力 ps aux | grep rails 起動している場合は以下のような表示。 2603 pts/3 Sl+ 0:04 /usr/local/rvm/rubies/ruby-2.2.1/bin/ruby bin/rails s -p 8080 -b 0.0.0.0 ここで、bin/railsを含む行の先頭のプロセスID(上記では2603、起動プロセスによって異なる)を指定して、プロセス終了。 $ kill (プロセスID) プロセスIDが2603の場合は以下のように実行します。 $ kill 2603 最後にrails s -p $PORT -b $IP で サーバー起動で状態確認
h_daido

2018/02/02 01:41

いいと思います! bundle install忘れもプロセス残りも、ちょくちょく遭遇するので、railsやるなら覚えておいて損ないですよ
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問