我的Rails项目中的方法是未定义的错误。插件回形针使用此方法。谁能告诉我我做错了什么?这是我的图片类的开头:
需要“回形针”
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
...
这是我的错误:
Extracted source (around line #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" %>
Application trace:
/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'
答案 0 :(得分:0)
您的模型中缺少attr_accessible
。
Paperclip有一些属性不属于您的模型,因此您必须明确将attr_accessor
设置为attr_accessor :attach