2011-12-07 4 views
0

で、私はよく、ユーザavatar.Evreryもの作品をアップロードするにはペーパークリップを使用していますが、私は、保存ボタンを押したとき、私はエラーを得た:ここ「関連タイプの不一致」?クリップ

ActiveRecord::AssociationTypeMismatch in UsersController#update 

    Usernote(#79841148) expected, got Array(#25890648) 

    Request 

Parameters: 

{"authenticity_token"=>"bLhGiceEIEohpuuclDpbmpzJR7SFb4HEY4+Qy9ER20E=", 
"_method"=>"put", 
"utf8"=>"✓", 
"id"=>"2", 
"user"=>{"user_information"=>{"passport_number"=>"", 
"passport_expiry_date"=>"", 
"gender"=>"Male", 
"birth_date"=>"", 
"marriage_date"=>"", 
"present_address"=>"", 
"blood_group"=>"", 
"emergency_contact"=>"", 
"marital_status"=>"Married"}, 
"usernotes"=>{"notes"=>"Hi this is First note from Ritz"}, 
"designation_id"=>"2", 
"username"=>"ritz", 
"reporting_to_id"=>"", 
"avatar"=>#<ActionDispatch::Http::UploadedFile:0x9514578 @headers="Content-Disposition: form-data; name=\"user[avatar]\"; filename=\"child ravi.jpg\"\r\nContent-Type: image/jpeg\r\n", 
@content_type="image/jpeg", 
@original_filename="child ravi.jpg", 
@tempfile=#<File:C:/Users/user/AppData/Local/Temp/RackMultipart20111207-2300-3nkxr9-0>>, 
"last_name"=>"roshan", 
"user_salary_detail"=>{"work_phone"=>"", 
"EPS_account_number"=>"", 
"work_type"=>"Permanent", 
"date_of_joining"=>"", 
"work_location"=>"", 
"branch"=>"", 
"PF_account_number"=>"", 
"bank_name"=>"", 
"PAN"=>"", 
"status"=>"Active", 
"bank_account_number"=>""}, 
"password"=>"[FILTERED]", 
"department_id"=>"1", 
"first_name"=>"hritwik", 
"email"=>"[email protected]"}} 

は私のモデルである:

class User < ActiveRecord::Base 
    has_attached_file :avatar, 
        :styles => { 
         :thumb => "75x75#", 
         :small => "100x100#", 
         :medium => "150x150>" 
        }, 
        :default => :thumb, 
        :url => "https://stackoverflow.com/users/user_avatar/:attachment/:id/:style/:basename.:extension", 
        :path => ":profitnext/public/images/users/user_avatar/:attachment/:id/:style/:basename.:extension" 

# avatar validations 
    validates_attachment_size :avatar, :less_than => 5.megabytes 
    validates_attachment_content_type :avatar, :content_type => ['image/jpeg', 'image/png'] 
end 

と私表示:

<%= image_tag @user.avatar.url %> 
       <%= image_tag @user.avatar.url(:thumb) %> 

私はエラーがbutton.I保存打った後、事前にこのlot.Thanksに苦しんだということです。

答えて

1

これはペーパークリップとは関係ありませんが、thisの行に沿っています。 Userモデルにhas_many :usernotes、Usernoteモデルにbelongs_to :userがありますか?

+0

私はユーザーノートのテーブルを持っていて、あなたと話している同じアソシエーションがあります。しかし、これは先に来ていません。 – Ravindra

+0

こんにちは私はその "usernotes"フィールドを削除しましたが、 "avatar" 、私は行方不明ですか?私を助けてください。 – Ravindra

+0

正確なエラーは何ですか?フォームを送信するときにこのエラーが表示されますか? – ramblex

関連する問題