未定义的方法`stringify_keys' [英] undefined method `stringify_keys'

查看:151
本文介绍了未定义的方法`stringify_keys'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



NoMethodError(未定义方法`stringify_keys'用于< ActionDispatch :: Http :: UploadedFile: )

  class MenuItem< 0x000000025387f0> ActiveRecord :: Base 
has_one:image


end

class图像< ActiveRecord :: Base
belongs_to:menu_item
has_attached_file:image,:styles => {
:large => 640x480,
:medium => 300x300,
:thumb => 100x100
}
end


解决方案

<



<$ p $>我曾经看到过这个错误发生之前,通常当人们尝试调用 update_attributes p> update_attributes(params [:image])

这:

  update_attributes(:image => params [:image])



黑暗中的一点点,但是如果这是我确信我们都会留下深刻的印象。


When I try to upload image using Paperclip gem I got this error:

NoMethodError (undefined method `stringify_keys' for <ActionDispatch::Http::UploadedFile:0x000000025387f0>)

class MenuItem < ActiveRecord::Base
 has_one :image


end

class Image < ActiveRecord::Base
 belongs_to :menu_item
 has_attached_file :image, :styles => {
            :large => "640x480",
            :medium => "300x300", 
            :thumb => "100x100" 
           }
end

解决方案

I've seen this error happen before, usually when people attempt to call update_attributes like this:

update_attributes(params[:image])

The call should actually be this:

update_attributes(:image => params[:image])

A bit of a shot in the dark, but if that's it I'm sure we'll all be impressed.

这篇关于未定义的方法`stringify_keys'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆