Ruby on rails rails 4回形针:缺少所需的属性存取器

Ruby on rails rails 4回形针:缺少所需的属性存取器,ruby-on-rails,paperclip,Ruby On Rails,Paperclip,我的回形针和滑轨有问题。 上载图像时,出现以下错误: Image model missing required attr_accessor for 'pic_file_name' 添加推荐的属性访问器时 attr_accessor :pic_file_name attr_accessor :pic_content_type attr_accessor :pic_file_size attr_accessor :pic_updated_at 记录已保存,但:pic列为空,未上载

我的回形针和滑轨有问题。 上载图像时,出现以下错误:

Image model missing required attr_accessor for 'pic_file_name'
添加推荐的属性访问器时

  attr_accessor :pic_file_name
  attr_accessor :pic_content_type
  attr_accessor :pic_file_size
  attr_accessor :pic_updated_at
记录已保存,但:pic列为空,未上载任何内容

我还尝试了白名单:pic\u file\u 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
def pic_file_name
 pic
end

def pic_file_name(file_name)
 pic = file_name
end
但是没有成功


有什么问题吗?

尝试实现pic\u文件名

 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
def pic_file_name
 pic
end

def pic_file_name(file_name)
 pic = file_name
end

我通过创建一个新专栏解决了这个问题

 def change
    add_column :images, :pic_file_name, :string
  end
可能是rails 4应用程序所必需的,我不知道。
现在可以了。

你是说进入模型?