【问题标题】:Fail assets compile when deploying to Heroku部署到 Heroku 时资产编译失败
【发布时间】:2013-03-03 21:01:30
【问题描述】:

我想将我的 Rails 应用程序部署到 heroku,但资产编译失败。在本地环境下,效果很好。

       Your bundle is complete! It was installed into ./vendor/bundle
       Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       rake aborted!
       Error: Parse error on line 13: Unexpected 'INDENT'
       (in /tmp/build_iztv4ybnwpqh/app/assets/javascripts/require_dir/view_after
_key_recieve.js.coffee)

日志显示第 13 行有意外缩进,但我找不到任何错误。

root = exports ? this
class root.ViewAfterKeyRecieveViewModel
  constructor: ->
    @isDecoded = ko.observable false
    @encryptedKey = ko.observable ''
    @personalPassword = ko.observable ''
    @decodePassword = ''

    # do when @personalPassword is changed
    ko.computed =>
      if @personalPassword() isnt ''
        @decodePassword = sjcl.decrypt(@personalPassword(), @encryptedKey())
      simg = new ScrambledImage044 "/assets/image61.png" # THIS IS LINE 13
        height: 16
        width:  12
        canvasId: 'original'
        seed:   @decodePassword
      simg.fix()
      simg.paint()

  createEncryptedKey: ->
    # create key and set to @encryptedKey
    @encryptedKey sjcl.encrypt("todo", "hirakegoma")

谢谢你的好意。

【问题讨论】:

标签: ruby-on-rails ruby coffeescript asset-pipeline


【解决方案1】:

试试这个:

simg = new ScrambledImage044 "/assets/image61.png",  # notice the comma
    height: 16
    width:  12
    canvasId: 'original'
    seed:   @decodePassword

或者这个:

simg = new ScrambledImage044( "/assets/image61.png"
    height: 16
    width:  12
    canvasId: 'original'
    seed:   @decodePassword
) # notice the parens

【讨论】:

  • 这确实很奇怪。以我的经验,在生产环境中编译 coffescript 总是有陷阱;我认为在这种模式下解析器配置默认值可能更严格(并且不允许某些同步糖),但我不能确定。我曾经疯狂地试图纠正这样一个错误,只是发现添加括号解决了这个问题......
猜你喜欢
  • 2021-04-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-26
  • 2014-01-09
  • 1970-01-01
  • 2012-11-29
  • 1970-01-01
相关资源
最近更新 更多