LoginSignup
1
0

More than 1 year has passed since last update.

【Docker×Rails6】solidusを使ってECサイトを構築する(開発編)

Last updated at Posted at 2021-08-19

この記事は、下記記事の続きになります。

gemをインストールする。

Gemfile
# frozen_string_literal: true
source "https://rubygems.org"
# gem "rails"
gem 'solidus'
gem 'solidus_auth_devise'

'solidus'をrequireすると、以下がまとめてインストールされます。個別にインストールすることも可能なよう。
solidus_core
solidus_api
solidus_frontend
solidus_backend
solidus_sample

docker-compose buildの実行

ターミナル
$ docker-compose build

docker環境の場合、通常は上記コマンドでbundle installができるはずなんですが、何故かできなかったため、下記実行。

ターミナル
$ docker-compose exec app bundle install

solidus用に必要なものをインストールする

ターミナル
① $ docker-compose exec app bundle exec rails generate spree:install

② $ docker-compose exec app bundle exec rails generate solidus:auth:install

③ $ docker-compose exec app bundle exec rails railties:install:migrations

④ $ docker-compose exec app bundle exec rails db:migrate

しかし、①を実行すると下記エラー発生。。。

エラー文
Running via Spring preloader in process 279
Could not find generator 'spree:install'.
Run `bin/rails generate --help` for more options.

試してみたこと

1.rubyのバージョン変更

2.7.1→2.7.2に変更したら上手くいったという記事を見て試してみましたが、駄目でした。。

2.キャッシュクリア

docker-compose exec app rm -rf tmp/cache/bootsnap-compile-cache
docker-compose exec app rm -rf tmp/cache/bootsnap-load-path-cache
docker-compose exec app bundle clean --force

こちらも変化なし。

①のエラーの解決策

$ docker-compose exec app bundle exec rails generate spree:install

ではなくて・・・・・

$ docker-compose exec app bundle exec rails g solidus:install

と実行したら成功しました!!

エラー文に、「Run bin/rails generate --help for more options.」
つまりhelpオプションをつけて実行してみて。と書かれていたので試してみましたが、すぐ解決したので、まずはエラー文に忠実に従ってみるのがいいということが、良く分かりました(^_^;)

**************************************************
We added the following line to your application's config/routes.rb file:

    mount Spree::Core::Engine, at: '/'
**************************************************
Solidus has been installed successfully. You're all ready to go!

Enjoy!

最終的に

デザインが反映されませんでした。。。
もしかするとrails6以降Webpackerでの管理になったが関係しているかも。。。
この記事を見ていただいた方は、rails6以前のバージョンで行うことをおすすめします。

スクリーンショット 2021-08-19 16.01.20.png

スクリーンショット 2021-08-19 16.01.49.png

▼参考にさせていただいた記事

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0