哈希和方括号的语法错误

时间:2015-05-14 05:26:00

标签: ruby-on-rails ruby annotate

我正在使用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:

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

1 个答案:

答案 0 :(得分:4)

 pass_through: @model.id

,缺失。