`

rails2.3.2 在windows下render :file的一个bug

    博客分类:
  • Ruby
阅读更多

在windows上render :file时使用绝对地址的时候,会出现invalid argument的错误,查看源码,发现错误在于rails对系统分隔符的判断有问题,要解决这个问题,修改以下两个文件:

1、ruby\lib\ruby\gems\1.8\gems\actionpack-2.3.2\lib\action_view\paths.rb,将其中的

 

 

return Template.new(original_template_path, original_template_path =~ /\A\// ? "" : ".") if File.file?(original_template_path)

替换为

 return Template.new(original_template_path, original_template_path =~ /\A(\/|[a-zA-Z]:)/ ? "" : ".") if File.file?(original_template_path)

 

 

 

2、 ruby\lib\ruby\gems\1.8\gems\actionpack-2.3.2\lib\action_view\template.rb,将

source 方法替换为

 

 

    def source

      if filename.match(/^\//)

        File.read(filename[1, filename.length])

      else

        File.read(filename)

      end

    end

 

分享到:
评论
1 楼 wentian914 2010-01-22  
这正是我要的..谢谢了.这个问题都给你找到了.牛

相关推荐

Global site tag (gtag.js) - Google Analytics