NameError:未初始化的常量ShopifyApp

时间:2018-04-12 15:35:27

标签: ruby-on-rails shopify-app

非常新的红宝石在轨道上。为这个问题的某些明显性质提前道歉。

我有一个新的rails应用程序,我在我的Gemfile中包含了shopify_app gem。尝试启动并运行应用程序时,我收到以下错误。

未初始化的常量ShopifyApp:在以下代码段中发生错误。

Rails.application.routes.draw do
  root :to => 'home#index'
  mount ShopifyApp::Engine, at: '/'  # this is the line throwing the error 

end

我的问题是,什么可能导致此错误被抛出?我相信这是在我运行bundle install时安装的(使用Gemfile中的shopify_app gem)如果您需要其他信息,请告诉我。正确方向的任何一点对我都有帮助。感谢。

以下是与之相关的完整跟踪。

config/routes.rb:3:in `block in <top (required)>'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:436:in `instance_exec'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:436:in `eval_block'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:418:in `draw'
config/routes.rb:1:in `<top (required)>'
railties (5.1.6) lib/rails/application/routes_reloader.rb:55:in `block in load_paths'
railties (5.1.6) lib/rails/application/routes_reloader.rb:55:in `each'
railties (5.1.6) lib/rails/application/routes_reloader.rb:55:in `load_paths'
railties (5.1.6) lib/rails/application/routes_reloader.rb:18:in `reload!'
railties (5.1.6) lib/rails/application/routes_reloader.rb:41:in `block in updater'
activesupport (5.1.6) lib/active_support/file_update_checker.rb:81:in `execute'
railties (5.1.6) lib/rails/application/routes_reloader.rb:25:in `execute'
railties (5.1.6) lib/rails/application/finisher.rb:141:in `block (2 levels) in <module:Finisher>'
activesupport (5.1.6) lib/active_support/callbacks.rb:413:in `instance_exec'
activesupport (5.1.6) lib/active_support/callbacks.rb:413:in `block in make_lambda'
activesupport (5.1.6) lib/active_support/callbacks.rb:197:in `block (2 levels) in halting'
activesupport (5.1.6) lib/active_support/callbacks.rb:601:in `block (2 levels) in default_terminator'
activesupport (5.1.6) lib/active_support/callbacks.rb:600:in `catch'
activesupport (5.1.6) lib/active_support/callbacks.rb:600:in `block in default_terminator'
activesupport (5.1.6) lib/active_support/callbacks.rb:198:in `block in halting'
activesupport (5.1.6) lib/active_support/callbacks.rb:507:in `block in invoke_before'
activesupport (5.1.6) lib/active_support/callbacks.rb:507:in `each'
activesupport (5.1.6) lib/active_support/callbacks.rb:507:in `invoke_before'
activesupport (5.1.6) lib/active_support/callbacks.rb:130:in `run_callbacks'
activesupport (5.1.6) lib/active_support/execution_wrapper.rb:108:in `run!'
activesupport (5.1.6) lib/active_support/reloader.rb:113:in `run!'
activesupport (5.1.6) lib/active_support/execution_wrapper.rb:70:in `block in run!'
activesupport (5.1.6) lib/active_support/execution_wrapper.rb:67:in `tap'
activesupport (5.1.6) lib/active_support/execution_wrapper.rb:67:in `run!'
activesupport (5.1.6) lib/active_support/reloader.rb:59:in `run!'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:10:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
web-console (3.6.0) lib/web_console/middleware.rb:137:in `call_app'
web-console (3.6.0) lib/web_console/middleware.rb:22:in `block in call'
web-console (3.6.0) lib/web_console/middleware.rb:20:in `catch'
web-console (3.6.0) lib/web_console/middleware.rb:20:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.6) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.6) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.6) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.4) lib/rack/method_override.rb:22:in `call'
rack (2.0.4) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.4) lib/rack/sendfile.rb:111:in `call'
railties (5.1.6) lib/rails/engine.rb:522:in `call'
puma (3.11.3) lib/puma/configuration.rb:225:in `call'
puma (3.11.3) lib/puma/server.rb:624:in `handle_request'
puma (3.11.3) lib/puma/server.rb:438:in `process_client'
puma (3.11.3) lib/puma/server.rb:302:in `block in run'
puma (3.11.3) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
This error occurred while loading the following files:

的Gemfile:

    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


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# 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', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Shopify App Gem - should include Shopify API as well
gem 'shopify_app'
# 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', platforms: [:mri, :mingw, :x64_mingw]
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '~> 2.13'
  gem 'selenium-webdriver'
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]

1 个答案:

答案 0 :(得分:0)

看起来你想要离开at: '/'。您只能指定NESTED路线,该路线不是/(根)。你只想在root中挂载。正如你在这里看到的那样,它会为你创造一堆路线。

https://github.com/Shopify/shopify_app#mounting-the-engine

安装引擎将提供使用您的应用程序验证商店的基本路线。默认情况下,它将提供:

Verb    Route   Action
GET '/login'    Login
POST    '/login'    Login
GET '/auth/shopify/callback'    Authenticate Callback
GET '/logout'   Logout
POST    '/webhooks/:type'   Webhook Callback