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

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

新規登録して質問してみよう
ただいま回答率
85.48%
Vue.js

Vue.jsは、Webアプリケーションのインターフェースを構築するためのオープンソースJavaScriptフレームワークです。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

1回答

1194閲覧

RailsにVue.jsを導入する

iyore888

総合スコア40

Vue.js

Vue.jsは、Webアプリケーションのインターフェースを構築するためのオープンソースJavaScriptフレームワークです。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

1クリップ

投稿2019/03/21 14:32

編集2019/03/24 12:20

#つまずいている事
下記の記事を参考にWebpackerを使用してRailsにVue.jsを導入しました。
その後rails g controllerした際に下記の'yarn'と'ActiveRecord'に関するエラーが発生して躓いております。。

参考URL:https://qiita.com/jnchito/items/30ab14ebf29b945559f6

#環境
ruby 2.6.0p0
Rails 5.1.6.2
vue@2.6.10
yarn 1.15.2

#エラーログ

command

1ユーザー:~/environment/vue.js-tutorial (master) $ rails g controller Home index 2warning Skipping preferred cache folder "/home/ec2-user/.cache/yarn" because it is not writable. 3warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-501". 4/home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/connection_specification.rb:188:in `rescue in spec': Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError) 5 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/connection_specification.rb:185:in `spec' 6 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:880:in `establish_connection' 7 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activerecord-5.1.6.2/lib/active_record/connection_handling.rb:58:in `establish_connection' 8 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activerecord-5.1.6.2/lib/active_record/railtie.rb:124:in `block (2 levels) in <class:Railtie>' 9 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval' 10 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook' 11 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control' 12 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook' 13 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/lazy_load_hooks.rb:50:in `block in run_load_hooks' 14 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/lazy_load_hooks.rb:49:in `each' 15 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks' 16 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activerecord-5.1.6.2/lib/active_record/base.rb:326:in `<module:ActiveRecord>' 17 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activerecord-5.1.6.2/lib/active_record/base.rb:25:in `<top (required)>' 18 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/dependencies.rb:292:in `require' 19 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/dependencies.rb:292:in `block in require' 20 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/dependencies.rb:258:in `load_dependency' 21 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/dependencies.rb:292:in `require' 22 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:356:in `active_record_configured?' 23 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:273:in `disconnect_database' 24 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:107:in `preload' 25 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:153:in `serve' 26 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run' 27 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop' 28 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `run' 29 from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>' 30 from /home/ec2-user/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 31 from /home/ec2-user/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 32 from -e:1:in `<main>'

#エラーへの対処
①エラーをググってみた
→効果的な解決策がヒットせず。
②ActiveRecordに関するエラーについて
→すでにSqlite3がインストール済みであることを確認。(Gemfileは以下。)

#Gemgile

ruby

1source 'https://rubygems.org' 2 3git_source(:github) do |repo_name| 4 repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") 5 "https://github.com/#{repo_name}.git" 6end 7 8 9# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 10gem 'rails', '~> 5.1.6' 11# Use sqlite3 as the database for Active Record 12gem 'sqlite3' 13# Use Puma as the app server 14gem 'puma', '~> 3.7' 15# Use SCSS for stylesheets 16gem 'sass-rails', '~> 5.0' 17# Use Uglifier as compressor for JavaScript assets 18gem 'uglifier', '>= 1.3.0' 19# See https://github.com/rails/execjs#readme for more supported runtimes 20# gem 'therubyracer', platforms: :ruby 21 22# Use CoffeeScript for .coffee assets and views 23gem 'coffee-rails', '~> 4.2' 24# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 25gem 'turbolinks', '~> 5' 26# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 27gem 'jbuilder', '~> 2.5' 28# Use Redis adapter to run Action Cable in production 29# gem 'redis', '~> 4.0' 30# Use ActiveModel has_secure_password 31# gem 'bcrypt', '~> 3.1.7' 32 33# Use Capistrano for deployment 34# gem 'capistrano-rails', group: :development 35 36 37group :development, :test do 38 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 39 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 40 # Adds support for Capybara system testing and selenium driver 41 gem 'capybara', '~> 2.13' 42 gem 'selenium-webdriver' 43end 44 45group :development do 46 # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. 47 gem 'web-console', '>= 3.3.0' 48 gem 'listen', '>= 3.0.5', '< 3.2' 49 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 50 gem 'spring' 51 gem 'spring-watcher-listen', '~> 2.0.0' 52end 53 54# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 55gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 56 57gem 'webpacker', github: 'rails/webpacker'

#追記:bundle installの結果

piyota08:~/environment/vue.js-tutorial (master) $ bundle The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. Using rake 12.3.2 Using concurrent-ruby 1.1.5 Using i18n 1.6.0 Using minitest 5.11.3 Using thread_safe 0.3.6 Using tzinfo 1.2.5 Using activesupport 5.1.6.2 Using builder 3.2.3 Using erubi 1.8.0 Using mini_portile2 2.4.0 Using nokogiri 1.10.1 Using rails-dom-testing 2.0.3 Using crass 1.0.4 Using loofah 2.2.3 Using rails-html-sanitizer 1.0.4 Using actionview 5.1.6.2 Using rack 2.0.6 Using rack-test 1.1.0 Using actionpack 5.1.6.2 Using nio4r 2.3.1 Using websocket-extensions 0.1.3 Using websocket-driver 0.6.5 Using actioncable 5.1.6.2 Using globalid 0.4.2 Using activejob 5.1.6.2 Using mini_mime 1.0.1 Using mail 2.7.1 Using actionmailer 5.1.6.2 Using activemodel 5.1.6.2 Using arel 8.0.0 Using activerecord 5.1.6.2 Using public_suffix 3.0.3 Using addressable 2.6.0 Using bindex 0.5.0 Using bundler 1.17.2 Using byebug 11.0.1 Using xpath 3.2.0 Using capybara 2.18.0 Using ffi 1.10.0 Using childprocess 0.9.0 Using coffee-script-source 1.12.2 Using execjs 2.7.0 Using coffee-script 2.4.1 Using method_source 0.9.2 Using thor 0.20.3 Using railties 5.1.6.2 Using coffee-rails 4.2.2 Using multi_json 1.13.1 Using jbuilder 2.8.0 Using rb-fsevent 0.10.3 Using rb-inotify 0.10.0 Using ruby_dep 1.5.0 Using listen 3.1.5 Using puma 3.12.1 Using rack-proxy 0.6.5 Using sprockets 3.7.2 Using sprockets-rails 3.2.1 Using rails 5.1.6.2 Using rubyzip 1.2.2 Using sass-listen 4.0.0 Using sass 3.7.3 Using tilt 2.0.9 Using sass-rails 5.0.7 Using selenium-webdriver 3.141.0 Using spring 2.0.2 Using spring-watcher-listen 2.0.1 Using sqlite3 1.4.0 Using turbolinks-source 5.2.0 Using turbolinks 5.2.0 Using uglifier 4.1.20 Using web-console 3.7.0 Using webpacker 4.0.2 from https://github.com/rails/webpacker.git (at master@554221c) Bundle complete! 17 Gemfile dependencies, 72 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed.

#お願い
一人では解決が難しいため
どなたかアドバイスをよろしくお願いします。

以上です。

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

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

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

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

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

ryochin

2019/03/22 02:06

現状で rails c が正常に実行できますか? bundler は利用していますか?
iyore888

2019/03/22 13:04

コメント頂きありがとうございます! rails cを実行した所エラーとなりました。(下記のエラー抜粋。) /home/ec2-user/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/bundler/resolver.rb:287:in `block in verify_gemfile_dependencies_are_found!': Could not find gem 'sqlite3 (~> 1.3.13)' in any of the gem sources listed in your Gemfile. (Bundler::GemNotFound) またbundlerは利用しています。 よろしくお願い致します。
ryochin

2019/03/23 04:22

bundler を利用しているということですから、bundle exec rails c を実行すべきかと思います。いずれにしても bundle install を実行した結果もほしいところです。
iyore888

2019/03/24 13:35

コメント頂き有難うございます! 本文にbundle installの結果を追記致しました。 bundle exec rails cというコマンドは調べてみて分からなかったのですが rails cと何か違いがあるのでしょうか? またbundle exec rails cの結果は文字数制限により下記に記載させて頂きます。 #### #追記:bundle exec rails cの結果 ``` ユーザー:~/environment/vue.js-tutorial (master) $ bundle exec rails c warning Skipping preferred cache folder "/home/ec2-user/.cache/yarn" because it is not writable. warning Selected the next writable cache folder in the list, will be "/tmp/.yarn-cache-501". /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/connection_specification.rb:188:in `rescue in spec': Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError) from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/connection_specification.rb:185:in `spec' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activerecord-5.1.6.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:880:in `establish_connection' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activerecord-5.1.6.2/lib/active_record/connection_handling.rb:58:in `establish_connection' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activerecord-5.1.6.2/lib/active_record/railtie.rb:124:in `block (2 levels) in <class:Railtie>' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/lazy_load_hooks.rb:50:in `block in run_load_hooks' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/lazy_load_hooks.rb:49:in `each' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activerecord-5.1.6.2/lib/active_record/base.rb:326:in `<module:ActiveRecord>' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activerecord-5.1.6.2/lib/active_record/base.rb:25:in `<top (required)>' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/dependencies.rb:292:in `require' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/dependencies.rb:292:in `block in require' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/dependencies.rb:258:in `load_dependency' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/activesupport-5.1.6.2/lib/active_support/dependencies.rb:292:in `require' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:356:in `active_record_configured?' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:273:in `disconnect_database' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:107:in `preload' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:153:in `serve' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `run' from /home/ec2-user/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>' from /home/ec2-user/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/ec2-user/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' from -e:1:in `<main>' ####
ryochin

2019/03/25 02:44

まず、bundler とは何か、何をするものかを理解してから Rails 開発を始めることをお勧めします。いずれにしても、sqlite3 gem が入っていないということですから、入れてみて下さい。
iyore888

2019/03/26 16:01

コメント有難う御座います。 bundlerはパッケージの種類やバージョンを管理、gemのインストールの際に必要なものという認識です。 また上記に記載しているgemfileにはsqlite3は記載しておりbundleも成功するため sqlite3のインストールはできているはずなのですがご指摘のように、 インストールするようにメッセージが出てしまいます。 この点について解決ができないためアドバイス頂けますと幸いです。
ryochin

2019/03/27 02:22

では、一度 gem を入れ直すのはどうでしょう。また、次のようにプロジェクトごとに入れるほうがトラブルが少なくなります。 rm -f .bundle/config rm -rf vendor/bundle bundle install --path=vendor/bundle bundle exec rails c
iyore888

2019/03/27 14:57

アドバイスありがとうございます。 アンインストール→インストールしてみましたがやはり同じエラーに戻ってしまいました。 yarnを入れる前のlinuxbrewのインストール時の挙動も少しおかしかったような気もしていますので 一度最初からやり直して見ようと思います。 長らくお時間取らせてしまい申し訳ありませんでした。 ありがとうございます。
guest

回答1

0

自己解決

環境構築を最初からやり直すことにしました。
もし原因がわかったら追記致します。

投稿2019/03/27 14:58

iyore888

総合スコア40

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問