使用 Rails 2.3.*(遗留项目,只是添加了一些功能),我收到回形针插件错误。我不确定为什么它告诉我该方法未定义。Paperclip 2.4.5 是在我使用 gem 列表检查我的 gem 时安装的。错误是:
undefined method `validates_attachment_content_type' for #<Class:0x107d4e1c8>
提取的源代码(在 #122 行附近):
119: <%= link_to 'Printable', { :action => 'print', :id => @incident.id }, { :target => '_blank', :class => "button" } %>
120: <% if isviewable?(@incident) %>
121:
122: <%= link_to "Pictures (#{@incident.pictures.count})", incident_pictures_path(@incident), :class => "button" %>
123: <%= link_to "Suspects (#{@incident.suspects.count})", incident_suspects_path(@incident), :class => "button" %>
应用程序跟踪:
/usr/local/rvm/gems/ruby-1.8.7-p371/gems/activerecord-2.3.11/lib/active_record/base.rb:1998:in `method_missing'
/Users/grantmc/Dev/railsprojects/Police/app/models/picture.rb:5
/Users/grantmc/Dev/railsprojects/Police/app/views/incidents/show.html.erb:122:in `_run_erb_app47views47incidents47show46html46erb'
这是我的图片模型类(picture.rb):需要“回形针”
class Picture < ActiveRecord::Base
validates_attachment_content_type :photo, :content_type => ['image/jpeg', 'image/png', 'image/pjpeg', 'image/gif','image/bmp']
validates_attachment_presence :photo, :message => 'is required'
belongs_to :incident
belongs_to :user
has_attached_file :photo,
:styles => {
:thumb => "50x50#",
:small => "150x150>",
:large => "800x800>",
:printable => "350x350"
}
end