我将Alchemy CMS添加到我之前正常运行的Spree项目中。但现在没有一条路线有效。对于所有路线,我得到一个页面not found error
。我已完成安装并运行了所有迁移。
Alchemy::Page not found "/"
ruby '2.2.4'
source 'https://rubygems.org'
gem 'rails', '4.2.5'
gem 'pg', '~> 0.15'
gem 'sass-rails'
gem 'uglifier'
gem 'coffee-rails'
gem 'jquery-rails'
gem 'turbolinks'
gem 'active_model_serializers'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spree', github: 'spree/spree', branch: 'master'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise'
gem 'puma'
gem 'paperclip'
gem 'aws-sdk', '< 2.0'
gem 'delayed_job_active_record'
gem 'alchemy_spree', github: 'magiclabs/alchemy_spree', branch: 'master'
# gem 'alchemy_cms', github: 'AlchemyCMS/alchemy_cms', branch: '3.1-stable'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
Rails.application.routes.draw do
mount Alchemy::Engine => '/'
mount Spree::Core::Engine, :at => '/shop'
end
# Tell Alchemy to use the Spree::User class
Alchemy.user_class_name = 'Spree::User'
Alchemy.current_user_method = :spree_current_user
# Load the Spree.user_class decorator for Alchemy roles
require 'alchemy/spree/spree_user_decorator'
# Include the Spree controller helpers to render the
# alchemy pages within the default Spree layout
Alchemy::BaseHelper.send :include, Spree::BaseHelper
Alchemy::BaseController.send :include, Spree::Core::ControllerHelpers::Common
Alchemy::BaseController.send :include, Spree::Core::ControllerHelpers::Store
module DistinctExistence
class Application < Rails::Application
config.to_prepare do
# Load application's model / class decorators
Dir.glob(File.join(File.dirname(__FILE__), '../app/**/*_decorator*.rb')) do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
# Load application's view overrides
Dir.glob(File.join(File.dirname(__FILE__), '../app/overrides/*.rb')) do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
Spree::UserSessionsController.class_eval do
include Alchemy::ControllerActions
end
end
config.time_zone = 'Central Time (US & Canada)'
config.active_job.queue_adapter = :delayed_job
config.active_record.raise_in_transactional_callbacks = true
end
end
Spree.config do |config|
# Example:
# Uncomment to stop tracking inventory levels in the application
# config.track_inventory_levels = false
end
Spree.user_class = 'Spree::User'
attachment_config = {
s3_credentials: {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
bucket: ENV['S3_BUCKET_NAME']
},
storage: :s3,
s3_headers: { 'Cache-Control' => 'max-age=31557600' },
s3_protocol: 'https',
bucket: ENV['S3_BUCKET_NAME'],
url: ':s3_domain_url',
styles: {
mini: '48x48>',
small: '100x100>',
product: '240x240>',
large: '600x600>'
},
path: '/:class/:id/:style/:basename.:extension',
default_url: '/:class/:id/:style/:basename.:extension',
default_style: 'product'
}
attachment_config.each do |key, value|
Spree::Image.attachment_definitions[:attachment][key.to_sym] = value
end
- name: article
hint: true
unique: true
contents:
- name: headline
type: EssenceText
default: :article_headline
hint: true
- name: picture
type: EssencePicture
hint: true
- name: text
type: EssenceRichtext
default: :article_text
hint: true
- name: product
contents:
- name: spree_product
type: EssenceSpreeProduct
- name: product_category
contents:
- name: spree_taxon
type: EssenceSpreeTaxon
- name: index
unique: true
elements: [article]
autogenerate: [article]
- name: product
elements: [product]
- name: products
elements: [product_category]
答案 0 :(得分:1)
炼金术在所有路线上都非常强大。请将Alchemy作为最后一个引擎安装在路径文件中:
Rails.application.routes.draw do
mount Spree::Core::Engine, :at => '/shop'
mount Alchemy::Engine => '/'
end
然后,每个特定引擎的所有路由都可以在其路由前缀下访问。
因此,要访问Spree管理员,您需要使用/shop/admin
,而Alchemy路线可以直接在/
下访问。
注意:要使重定向到登录路径有效,您需要告诉Alchemy。按照上面的示例,如果您使用的是spree_auth_devise
:
# config/initializers/alchemy.rb
Alchemy.login_path = '/shop/login'
或者,如果您使用自己的自定义身份验证:
# config/initializers/alchemy.rb
Alchemy.login_path = '/sessions/new'