簡體   English   中英

耙db:migrate不適用於回形針

[英]rake db:migrate not working with 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

如編譯器所述,這是語法錯誤。

這行:

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

應更改為:

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

問題不在於遷移,而是您使用Paperclip的語法:

 has_attached_file :image, styles: {

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM