2013-01-13 1 views
1

내 사용자 모델에 여러 개의 첨부 파일을 사용하고 싶습니다. 아바타 및 표지 사진. 나는 클립 클립을 사용하고 있습니다.한 모델에 여러 개의 서로 다른 첨부 파일 | 종이 클립

현재 새 아바타를 업로드 할 수 있지만 표지 사진을 업데이트 할 때마다 오류가 발생합니다. 이미 로그인되어 있습니다.. 나는 인증을 위해 devise를 사용하고 있습니다.

내 모델 :

# Include default devise modules. Others available are: 
    # :token_authenticatable, :confirmable, 
    # :lockable, :timeoutable and :omniauthable 
    devise :database_authenticatable, :registerable, 
     :recoverable, :rememberable, :trackable, :validatable 

    # Setup accessible (or protected) attributes for your model 
    attr_accessible :email, :password, :password_confirmation, :remember_me, :firstname, :lastname, :username, :login, :avatar 

    has_many :wishes 

    # Virtual attribute for authenticating by either username or email 
    # This is in addition to a real persisted field like 'username' 
    attr_accessor :login 

    validates_uniqueness_of :username 

    # hide instead of deleting 
    acts_as_paranoid 

    # tracking 
    # include PublicActivity::Model 
    # tracked owner: Proc.new{ |controller, model| controller.current_user } 

    # Avatar - Paperclip 
    has_attached_file :avatar, 
        :styles => { 
         :extra_large => "600x600#", 
         :large => "400x400#", 
         :medium => "250x250#", 
         :small => "145x145#", 
         :tiny => "45x45#", 
         :icon => "16x16#" 
        }, 
        :default_url => '/assets/default-user-avatar/:style.jpg' 

    # Avatar - Paperclip 
    has_attached_file :cover_photo, 
        :styles => { 
         :large => "940x360#", 
         :extra_large => "1880x720#" 
        } 

    # Versions 
    has_paper_trail 

    searchable do 
    text :username, :boost => 5 
    text :firstname 
    text :lastname 
    text :email 
    end 

양식 :

<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => ({ :method => :put, :multipart => true })) do |f| %> 
    <%= f.error_notification %> 

    <div class="form-inputs"> 
    <%= f.input :firstname %> 
    <%= f.input :lastname %> 
    <%= f.input :username, :wrapper => :prepend do %> 
     <span class="add-on">@</span> 
     <%= f.input_field :username %> 
    <% end %> 
    <%= f.input :email, :required => true, :autofocus => true %> 
    <%= f.input :password, :autocomplete => "off", :hint => "leave it blank if you don't want to change it", :required => false %> 
    <%= f.input :password_confirmation, :required => false %> 
    <%= f.input :current_password, :hint => "we need your current password to confirm your changes", :required => true %> 

    Avatar:<br/> 
    <%= f.file_field :avatar %><br/> 
    Cover Photo:<br/> 
    <%= f.file_field :cover_photo %><br/> 
    </div> 

    <div class="form-actions"> 
    <%= f.button :submit, "Update" %> 
    </div> 
<% end %> 

너희들이 나를 도울 수 있기를 바랍니다!

당신은 추가 할 수 있습니다

답변

0

:이 라인에 cover_photo : 또한

attr_accessible :email, :password, :password_confirmation, :remember_me, :firstname, :lastname, :username, :login, :avatar, :cover_photo 

... 그리고 당신이 당신의 데이터베이스에서 설정 한 cover_photo 열을 가지고 있는지 확인

관련 문제