我有一个主题,我经常在我的网站上使用。我一直试图通过一个宝石加载CSS,JS和插件文件夹(包含在主题中)。使用宝石加载资产(遇到问题不会加载资产)
Sprockets::FileNotFound: couldn't find file 'phcthemes' with type 'application/javascript'
如果我拿出的JavaScript(CSS)此不执行,准确地显示出来这样在编译的资产
*= phcthemes
我的想法应用程序是不承认的宝石,我试过使用isolate_namespace(现在注释掉)也尝试了几种不同的配置,使用以下答案中的信息无济于事。
主要应用application.css
*= phcthemes
主要的应用程序的application.js
// require phcthemes
LIB/phcthemers.rb
require "phcthemes/version"
module Phcthemes
class MyRailtie < Rails::Railtie
end
class Engine < ::Rails::Engine
# Isolate Namespace
#isolate_namespace Phcthemes
# Initialize Assets
initializer :assets do |config|
Rails.application.config.assets.precompile += %w{ application.js application.css }
Rails.application.config.assets.paths << root.join("app", "assets", "javascripts")
Rails.application.config.assets.paths << root.join("app", "assets", "stylesheets")
end
end
end
phcthemes.gemspec
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "phcthemes/version"
Gem::Specification.new do |spec|
spec.name = "phcthemes"
spec.version = Phcthemes::VERSION
spec.authors = ["BradPotts"]
spec.email = ["[email protected]"]
spec.homepage = "http://phcnetworks.net"
spec.summary = "PHCThemes"
spec.description = "PHCNetworks theme with mtdevise and assets built in."
spec.license = "GPL-3.0"
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.files = Dir["{app,config,db,lib}/**/*", "LICENSE", "Rakefile", "README.md"]
# Main Structure & Security
spec.add_dependency "rails", "~> 4.2.5.2"
# Development & Testing
spec.add_development_dependency "sqlite3"
spec.add_development_dependency "bundler", "~> 1.11"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.0"
end
感谢您的答案马克斯,它看起来应该工作,但不因为某种原因与我。顺便说一句,感谢您的项目链接真的帮助我。我更新了我提出的更多信息和更改。将继续在此工作。 – bradpotts
@bradpotts它看起来像你的问题中的css/js需要语句仍然是错误的,它应该是'* = require phcthemes'和'// = require phxthemes'。如果没有等号表示依赖项未被加载。等号后的'require'这个词也是必需的,无论是在CSS还是JS –
谢谢你的帮助。我做了改变。我仍然有同样的错误,但我感到满意,因为它看起来是正确的,并使我朝着正确的方向前进。如果你注意到其他事情,请让我知道。 – bradpotts