代码之家  ›  专栏  ›  技术社区  ›  Brendon Baughn

rake db:迁移不使用回形针

  •  1
  • Brendon Baughn  · 技术社区  · 10 年前

    我正在使用回形针,我正在尝试重新整理我的迁移文件,但我遇到了一个错误:

    SyntaxError: /Users/Brendon/Desktop/savings/app/models/user.rb:5: syntax error, unexpected '{', expecting keyword_end
    ...attached_file :image, :styles { large: '600x600>', medium: '...
    ...                               ^
    /Users/Brendon/Desktop/savings/app/models/user.rb:5: syntax error, unexpected ',', expecting keyword_end
    ...e, :styles { large: '600x600>', medium: '300x300>', thumb: '...
    ...                               ^
    /Users/Brendon/Desktop/savings/app/models/user.rb:5: syntax error, unexpected ',', expecting keyword_end
    ...'600x600>', medium: '300x300>', thumb: '150x150#' }
    

    我不知道这是怎么回事,我的耙。没有意外的“{”

    class User < ActiveRecord::Base
      # Include default devise modules. Others available are:
      # :confirmable, :lockable, :timeoutable and :omniauthable
    
      has_attached_file :image, :styles { large: '600x600>', medium: '300x300>', thumb: '150x150#' }
      validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/
    
      devise :database_authenticatable, :registerable,
             :recoverable, :rememberable, :trackable, :validatable
    end
    
    2 回复  |  直到 10 年前
        1
  •  0
  •   Onichan    10 年前

    这是编译器指出的语法错误。

    此行:

    has_attached_file :image, :styles { large: '600x600>', medium: '300x300>', thumb: '150x150#' }
    

    应更改为:

    has_attached_file :image, styles: { large: '600x600>', medium: '300x300>', thumb: '150x150#' }
    
        2
  •  0
  •   Richard Peck    10 年前

    问题不在于迁移,而是你的Paperclip语法:

     has_attached_file :image, styles: {