2013-10-18 2 views
1

내가 클립에 문제가 attr_accessor 필요하고 이미지를 업로드 할 때 4. 레일 누락, 나는 다음과 같은 오류가 발생합니다 :레일 4 클립은 :

Image model missing required attr_accessor for 'pic_file_name' 

권장 attr_accessors

attr_accessor :pic_file_name 
    attr_accessor :pic_content_type 
    attr_accessor :pic_file_size 
    attr_accessor :pic_updated_at 
추가

레코드가 저장되었지만 : 그림 열이 비어 있고 아무것도 업로드되지 않았습니다. pic_file_name

private 
    # Use callbacks to share common setup or constraints between actions. 
    def set_image 
     @image = Image.find(params[:id]) 
    end 

    # Never trust parameters from the scary internet, only allow the white list through. 
    def image_params 
     params.require(:image).permit(:title, :pic, :pic_file_name) 
    end 

하지만 성공 :

는 또한 화이트리스트를 시도했다.

어떤 아이디어가 잘못 되었습니까?

답변

3

시도 구현 pic_file_name, 모른다. 작동 중입니다.

0

내가

def change 
    add_column :images, :pic_file_name, :string 
    end 

4 응용 레일이 필요할 수 있습니다 새 열을 만들어이 문제를 해결 한

def pic_file_name 
pic 
end 

def pic_file_name(file_name) 
pic = file_name 
end 
+0

당신은 모델을 의미합니까? – DonMB