【问题标题】:Syntax error with hash and square brackets带有哈希和方括号的语法错误
【发布时间】:2015-05-14 05:26:00
【问题描述】:

我正在使用 Rails 4.1.6 和 Ruby 2.1.5。

我有以下代码,但出现错误:

params = {
  input: @model.video.url,
  test: true,
  notifications: [zencoder_url],
  pass_through: @model.id
  outputs: [
    {
      public:       true,
      base_url:     base_url,
      filename:     "mp4_" + filename_without_ext + '.mp4',
      label:        'webmp4',
      format:       'mp4',
      audio_codec:  'aac',
      video_codec:  'h264'
    },
    {
      public:       true,
      base_url:     base_url,
      filename:     "web_" + filename_without_ext + '.webm',
      label:        'webwebm',
      format:       'webm',
      audio_codec:  'vorbis',
      video_codec:  'vp8'          
    },
    {
      public:       true,
      base_url:     base_url,
      filename:     "ogv_" + filename_without_ext + '.ogv',
      label:        'webogv',
      format:       'ogv',
      audio_codec:  'vorbis',
      video_codec:  'theora'          
    },
    {
      thumbnails: {
        public:       true,
        base_url:     base_url,
        filename:     "thumbnail_" + filename_without_ext,
        times:        [3],
        aspect_mode:  'preserve',
        width:        '100',
        height:       '100'
      }
    }
  ]
}

这是我在尝试访问我的应用中的任何页面时遇到的错误:

Started GET "/" for 127.0.0.1 at 2015-05-14 00:26:08 -0500
  ActiveRecord::SchemaMigration Load (3.0ms)  SELECT "schema_migrations".* FROM "schema_migrations"
  User Load (6.3ms)  SELECT  "users".* FROM "users"  WHERE "users"."id" = 57  ORDER BY "users"."id" ASC LIMIT 1
Processing by DashboardController#index as HTML
Completed 500 Internal Server Error in 12ms

SyntaxError - syntax error, unexpected tIDENTIFIER, expecting '}'
      outputs: [
             ^
/app/uploaders/video_uploader.rb:102: syntax error, unexpected '}', expecting keyword_end:

什么可能导致此错误?语法对我来说似乎是合法的。我似乎没有遗漏任何花括号或方括号。

【问题讨论】:

    标签: ruby-on-rails ruby annotate


    【解决方案1】:
     pass_through: @model.id
    

    , 不见了。

    【讨论】:

    • 啊……当然。非常感谢孟。我什至没有测试过,但这似乎是准确的!编辑:经过测试,没错!
    • @marcamillion 因为这个答案对你有帮助,请将答案标记为正确。
    • @MohammadAbuShady,没有选择答案,因为它们是正确的;选择了一个答案,因为它是 OP 发现的最有用的答案。在这种情况下,可能没有其他答案,但总的来说,选择答案并不急,OP 必须记住最终这样做(前提是至少有一个答案有帮助)。许多 SO 成员至少要等几个小时才能选择答案。快速选择可能会阻止其他可能更好的答案,并且当绿灯亮起时,对那些仍在研究答案的人是不礼貌的。
    • @CarySwoveland 我只是想提醒他,因为很多问题都得到了回答,并且 OP 确认了答案,但他们仍未解决。很多时候我会通过问题并花几分钟阅读问题只是为了发现它已经在评论中得到了回答。
    • 我打算将其标记为正确,但他回答得太快以至于阻止了我。我让标签打开以记住,所以我就这样做了。无论如何感谢您的提醒@MohammadAbuShady
    猜你喜欢
    • 1970-01-01
    • 2015-06-09
    • 1970-01-01
    • 2015-08-13
    • 2015-10-27
    • 2015-11-29
    • 2011-01-04
    • 2012-09-02
    • 2015-03-02
    相关资源
    最近更新 更多