rails 3.2 LESS CSS和heroku?

oma*_*oma 2 ruby-on-rails heroku less asset-pipeline

想要尝试新的东西,使用真棒的twitter bootstrap和他们的Less CSS.我终于启动并运行了我的应用程序,但它在heroku的只读系统中崩溃了.我正试图找出我的选择,使用LESS,rails 3.2和heroku.这是我认为可以做的:

(1)一种选择是:预编译.

 bundle exec rake assets:precompile
 git commit public/assets -m "tedious precompilation task"
 git push heroku
Run Code Online (Sandbox Code Playgroud)

我肯定会忘记预编译一次,只需将更改推送到heroku并让我的用户感到烦恼.不是我想要的.

(2)一个好的选择是less.js.它编译客户端.这是最常用的吗?

(3)更好的选择,IMO.预编译缓存.预编译例程和额外的客户端都不起作用.我问的是,是否有类似SASS的麻烦,少花钱?

UPDATE 26th jan-12:人们不使用麻烦的轨道3.1+,他们使用资产管道的sass-rails(默认rails 3.2).麻烦是sooo rails 3.0;)rake预编译步骤在heroku失败了./ UPDATE

我发现编译为静态机架缓存的想法绝对非常出色.我更喜欢它让每个客户端都需要在部署时一次性完成编译我的较少css.

更新25日1月:在heroku上更新自己.雪松堆栈支持资产管道,因此不再需要麻烦的宝石.正确?/ UPDATE

该怎么办?

oma*_*oma 6

解:

application.rb
  config.assets.initialize_on_precompile = false
Run Code Online (Sandbox Code Playgroud)

简单的解决方案,一旦你知道它....!

使用gem less-rails 现在所有资产都已编译并将被缓存(如选项3所示).资产管道真棒!

问题背景:

Heroku无法预编译为rails pr默认尝试初始化并附加到DB,但ENV vars尚不可用.没有它,你会得到

$ git push heroku

Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Run Code Online (Sandbox Code Playgroud)

就像一个注释:Heroku也有一种在预编译阶段提供环境变量的方法.

$ heroku plugins:install http://github.com/heroku/heroku-labs.git
$ heroku labs:enable user_env_compile  [--app my_app]
Run Code Online (Sandbox Code Playgroud)