论坛首页 编程语言技术论坛

关于Rails2.0下的File-Column插件使用

浏览 2732 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2008-03-21  
在rails2.0以下版本下开发的时候,参照“整合File-Column和Rmagick功能实现图片上传“http://airport.iteye.com/blog/33216
就可以实现图片的上传。
但是在rails2.0中,当在show.html.erb实现图片显示:
原始大小:
  <%= image_tag url_for_file_column 'entry', 'image' %>
  <br>
  thumb:
  <%= image_tag url_for_file_column 'entry', 'image' ,'thumb'%>
报错提示:
Showing groups/show.html.erb where line #2 raised: 

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.relative_url_root

Extracted source (around line #2): 

1: <div id="group" class="group">
2:  <%= image_tag url_for_file_column 'group', 'ico' %>
3: </div>
4: <div id="gcomments" class="gcomments">
5: 


查找了很多地方,没有找到答案。
   发表时间:2008-03-24  
<%= image_tag url_for_file_column 'group', 'ico' %>  


'group'要改成你的实例名,如实例为@user等
<%= image_tag url_for_file_column @user, 'ico' %>
0 请登录后投票
   发表时间:2008-04-14  
pure 写道
<%= image_tag url_for_file_column 'group', 'ico' %>  


'group'要改成你的实例名,如实例为@user等
<%= image_tag url_for_file_column @user, 'ico' %>

我也遇到了这个问题,
nil.relative_url_root的异常是由file_column_helper中的url_for_file_column方法抛出来的,是因为在url_for_file_column方法中还使用"@request"访问Request,只要删了'@',使用Rails 2.0的request代替@request就可以了
0 请登录后投票
论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics