我正在尝试使用Shopify宝石建立在线商店。我已将gem shopify_api
添加到Gemfile中,并运行bundle install
和bundle update
。但是,当我运行下一条命令时:
rails generate shopify_app -api_key=[API_KEY_HERE]-secret=[SECRET_KEY_HERE]
我收到以下错误:
Could not find generator 'shopify_app'. Maybe you meant 'scaffold', 'scss:assets' or 'controller'
Run `rails generate --help` for more options.
我尝试重新启动Rails服务器,但没有任何效果。为什么我会收到此错误,该怎么办?
宝石文件:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem 'shopify_api'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.6'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.18'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# 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.2'
# 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 navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'simple_form'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
运行命令rails generate --help
时,我得到以下信息
C:\Sites\postgresapp>rails generate --help
Usage: rails generate GENERATOR [args] [options]
General options:
-h, [--help] # Print generator's options and usage
-p, [--pretend] # Run but do not make any changes
-f, [--force] # Overwrite files that already exist
-s, [--skip] # Skip files that already exist
-q, [--quiet] # Suppress status output
Please choose a generator below.
Rails:
assets
channel
controller
generator
helper
integration_test
jbuilder
job
mailer
migration
model
resource
scaffold
scaffold_controller
task
Coffee:
coffee:assets
Graphql:
graphql:enum
graphql:install
graphql:interface
graphql:loader
graphql:mutation
graphql:object
graphql:union
Js:
js:assets
SimpleForm:
simple_form:install
TestUnit:
test_unit:generator
test_unit:plugin
编辑:我已经找到了我的问题的部分答案。从Gem文档中指出:
此gem需要从4.3版本开始使用Ruby 2.3.1。如果您需要使用 较旧的Ruby版本,然后更新您的Gemfile以锁定到较旧的版本 版本高于4.3。
由于我使用的是ruby 2.2.6版,因此需要指定旧版gem。因此我将问题进一步缩小到:我如何知道要使用哪个版本的Shopify宝石?
答案 0 :(得分:0)
bundle list
将列出您所有的宝石及其版本
bundle list | grep shopify
将为您显示有关Shopify宝石的详细信息
答案 1 :(得分:0)
我认为您需要将gem 'shopify_app'
包含在gemfile中,然后再次捆绑安装。我可以看到您拥有shopify_api
宝石,但没有shopify_app
宝石,它具有发生器。