我知道最好在虚拟机上使用这个 cms,比如 linux 等操作系统(因为这个命令:$ wagon serve
根本不在 Windows 上运行)我决定使用 nitrous io,它工作得非常好(在 ubuntu 上) os) 唯一的问题是当我对我的机车 cms 安装进行预览时,它显示的后端没有样式 (css)。
Rails 3.2.19 红宝石 2.1.0
我在这里逐步运行的命令对我不起作用:首先,我的 gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '3.2.19'
gem 'locomotive_cms', '~> 2.4.1', :require => 'locomotive/engine'
group :assets do
gem 'compass', '~> 0.12.7'
gem 'compass-rails', '~> 1.0.2'
gem 'sass-rails', '~> 3.2.6'
gem 'coffee-rails', '~> 3.2.2'
gem 'uglifier', '~> 2.5.1'
gem 'therubyracer', :platforms => :ruby
end
# Use unicorn as the app server
gem 'unicorn'
gem 'rake', '10.0.4'
正如 locomotivecms 文档中所建议的,我开始为引擎创建一个新的 rails 项目:
$ rails new codigos_comentados_engine --skip-active-record --skip-test-unit --skip-javascript --skip-bundle
$ bundle
创建 locomotivecms 引擎:
$ rails generate locomotive:install
然后,项目中的一些文件在 environment/production.rb 和 environment/development.rb 中不起作用:
Error: undefined method `configure' for #<CodigosComentadosEngine::Application:0x007f8
03fe43bf0> (NoMethodError)
更改此问题时解决:
Rails.Aplication.configure do
这样:
CodigosComentadosEngine::Application.configure do
然后,机车引擎运行良好,我得到了这个不错的输出:
1. blah blah
2. bundle exec unicorn_rails
3. Open your browser
open localhost:8080
4. Follow the installation wizard steps
5. Enjoy !
然后:
$ bundle exec unicorn_rails
我收到了这个警告但是服务器仍然在工作:
WARNING: unable to load the content types, Could not connect to any secondary or primary nodes for replica set <Moped::Cluster nodes=[<Moped::Node resolved_address="127.0.0.1:270
17">]>
好的。当我在浏览器中打开此网址时:myprojectblahblahblah.nitrousbox.com:8080
我收到了下一条消息:
ArgumentError: A secret is required to generate an integrity hash for cookie session data. Use config.secret_token = "some secret phrase of at least 30 characters"in config/initializers/secret_token.rb
好的。我在 config/initializers/secret_token.rb 中创建了秘密令牌文件
CodigosComentadosEngine::Application.config.secret_token = 'blahblahblahblahblahblahblahblahblahblahblah'
根据 nitrous 帮助文档安装 mongodb:
$ parts install mongodb
启动mongodb:
$ parts start mongodb
ok. => Started: mongodb
再次启动服务器独角兽:
$ bundle exec unicorn_rails
一切都没事。 ...
在浏览器中预览:myprojectblahblahblah.nitrousbox.com:8080
但是后端的样式没有出现,加载everthing,没有样式我什至可以创建一个用户并查看我的网站。
当我检查 html 时<script></script>
,头部的路径是:
myprojectblahblah.nitrousbox.com:8080/javascripts/locomotive/not_logged_in.js
myprojectblahblah.nitrousbox.com:8080/stylesheets/locomotive/not_logged_in.css
在一个论坛中,我发现这一步一步对他们有用,而不是我在 ubuntu 上使用 nitrous:链接 [ https://locomotivecms.tenderapp.com/discussions/problems/309-backend-themestyles-does-not-apply-丢失文件重新打开#comment_31593155][1]
为了使链接中的 public/assets 目录“出现”,建议运行以下命令:
$ RAILS_ENV=production bundle exec rake assets:precompile
运行此命令后,我得到以下输出:
Digest::Digest is deprecated; use Digest
/home/action/.parts/packages/ruby2.1/2.1.1/bin/ruby /home/action/.gem/ruby/2.1.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
Digest::Digest is deprecated; use Digest
但是 puplic/assets 没有出现在目录中,并且在机车的后端没有显示任何样式(表单和 web 正在加载)
之后,我运行了相同的命令,但使用了 --trace,我得到了以下输出:
$ RAILS_ENV=production bundle exec rake --trace assets:precompile
输出:
rake aborted!
Don't know how to build task 'default'
/home/action/.gem/ruby/2.1.1/gems/rake-10.0.4/lib/rake/application.rb:142:in `invoke_task'
...
/home/action/.gem/ruby/2.1.1/gems/rake-10.0.4/bin/rake:33:in `<top (required)>'
/home/action/.gem/ruby/2.1.1/bin/rake:23:in `load'
/home/action/.gem/ruby/2.1.1/bin/rake:23:in `<main>'
我用谷歌搜索“rake aborted!不知道如何构建任务'default'”,我注意到在 Rakefile 中我有这一行:
`Rails.application.load_tasks`
我改变了:
CodigosComentadosEngine::Application.load_tasks
我在 GemFile 中添加了这一行: gem rake '10.0.4'
然后我运行这个命令并成功输出:(RAILS_ENV=development 和 RAILS_ENV=production 都返回一个成功的输出)
$ RAILS_ENV=development bundle exec rake --trace assets:precompile
输出:
/home/action/.parts/packages/ruby2.1/2.1.1/bin/ruby /home/action/.gem/ruby/2.1.1/bin/rake assets:precompile:all RAILS_ENV=development RAILS_GROUPS=assets --trace
Digest::Digest is deprecated; use Digest
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
**.....
** Execute assets:precompile:primary
....
之后,(根据我发布的论坛链接)的想法是您必须查看 public/assets 目录,但我没有看到它。奇怪的是,当我在 Windows (7) 上安装它时,后端样式加载完美,问题是$wagon serve command
,这是一个已知的 win 问题。
我将在本地尝试使用 ubuntu,没有亚硝酸盐。如果我成功了,我会更新这个问题。你对这个 cms 和nitrous有类似的问题吗?
PS。对不起,我的英语可能并不完美。谢谢你的帮助!