我正在使用Paperclip,我正在尝试搜索我的迁移文件但是我收到了错误:
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
答案 0 :(得分:0)
这是编译器指出的语法错误。
这一行:
has_attached_file :image, :styles { large: '600x600>', medium: '300x300>', thumb: '150x150#' }
应改为:
has_attached_file :image, styles: { large: '600x600>', medium: '300x300>', thumb: '150x150#' }
答案 1 :(得分:0)
问题不在于迁移,而是Paperclip的语法:
has_attached_file :image, styles: {