2008-03-21

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

关键字: rails2.0; file_column
在rails2.0以下版本下开发的时候,参照“整合File-Column和Rmagick功能实现图片上传“http://airport.javaeye.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: 


查找了很多地方,没有找到答案。
评论
distortion 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就可以了
pure 2008-03-24
<%= image_tag url_for_file_column 'group', 'ico' %>


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

提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则

您还没有登录,请登录后发表评论

kenrome
搜索本博客
博客分类
最近加入圈子
存档
最新评论