Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails lambda函数如何在rails中工作?以回形针gem为例_Ruby On Rails_Ruby_Lambda_Paperclip - Fatal编程技术网

Ruby on rails lambda函数如何在rails中工作?以回形针gem为例

Ruby on rails lambda函数如何在rails中工作?以回形针gem为例,ruby-on-rails,ruby,lambda,paperclip,Ruby On Rails,Ruby,Lambda,Paperclip,我对回形针gem有一个问题,在生产环境中对其进行指纹识别后,default\u url无法加载,我的代码如下: class User # Attachments to Paperclip - Profile pic has_attached_file :profilepic_attachment, :styles => { thumb: '100x100#',

我对回形针gem有一个问题,在生产环境中对其进行指纹识别后,
default\u url
无法加载,我的代码如下:

class User

# Attachments to Paperclip - Profile pic
  has_attached_file :profilepic_attachment, 
                    :styles => { 
                      thumb: '100x100#',
                      square: '500x500#'
                    },
                    :default_url => ActionController::Base.helpers.asset_path("missing/default_user.png"),
                    :preserve_files => true
  validates_attachment_content_type :profilepic_attachment, content_type: /\Aimage\/.*\Z/

end
请注意,当我在生产中执行rails c并打印出
ActionController::Base.helpers.asset\u path(“missing/default\u user.png”)
时。打印出指纹版本(正确版本)。
default_user-fb34158daae99f297ad672c43bb1a4d3917d8e272b5f2254aa055392aa2faa94.png

然而,当我从浏览器中检查它时,原来的
/assets/missing/default_user.png
出现了

我挣扎了很长一段时间,直到我遇到这个问题,这告诉我要改变

:default\u url=>ActionController::Base.helpers.asset\u路径(“缺少/default\u user.png”)

:default_url=>lambda{| image | ActionController::Base.helpers.asset_path(“missing/default_user.png”)

我不确定发生了什么,但后来它成功了。然后我想知道lambda函数的作用是什么,它什么时候用于rails?此外,它还传入了一个变量
|image |
,但似乎没有在代码中使用。为什么呢

谢谢