2013-05-14 2 views
0

내 Rails 프로젝트에서 정의되지 않은 오류가 발생합니다. 이 방법은 플러그인 클립에 의해 사용됩니다. 아무도 내가 뭘 잘못하고 있다고 말할 수 있습니까? 여기에 내 사진 클래스의 시작이다 : 당신은 당신의 모델 attr_accessible 누락정의되지 않은 클립 방법

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

:

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 
... 

여기 내 오류입니다 "클립"을 필요로한다.

종이 클립은 모델의 일부가 아닌 일부 속성을 가지고, 그래서 당신은 내가`attr_accesor 필요가이 경우에 따라서 attr_accessor :attach

+0

같은 그들에게 attr_accessor에 명시 적으로 asign이 내 모델 photo'을? – grantmcconnaughey

+0

예, 모델에 attr_accesor : photo를 추가해야합니다. – sunny1304

+0

불행히도이 코드 줄을 추가하면 똑같은 오류가 발생합니다. 오류 메시지는 validates_attachment_content_type 메소드를 인식하지 못하기 때문에 어떤 이유로 모델이 클립 클립을 볼 수 없다고 생각합니다. – grantmcconnaughey

관련 문제