迁移rails 2.0.2到2.3.5后,Image_tag不起作用

时间:2009-12-26 11:18:42

标签: ruby-on-rails ruby

我想将rails应用程序2.0.2升级到2.3.5。在遇到mysql的许多问题后,我的应用程序出现了另一个大问题。

问题在于:

Processing UserController#profil (for 127.0.0.1 at 2009-12-26 11:47:13) [GET]
Rendering template within layouts/admin
Rendering user/profil

ActionView::TemplateError (undefined method `image_tag' for #<ActionView::Base:0x1032bef18>) on line #57 of app/views/user/profil.html.erb:
54: <div style="float: left; width: 300px;" >
55: <%= render :partial => 'shared/cadre', :locals => {:style => '', :modif => modif,
56:  :title => 'AVATAR', :width => 200,
57:  :display => image_tag(@userView.GetAvatar, :class => 'ie200', :style => 'max-height: 200px; max-width: 200px;') } -%>
58: <div style="position: relative;" >
59: <div class="menu-profil" >
60:  <select id="menuProfil" name="my-dropdown" >

app/views/user/profil.html.erb:57
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'

Rails不知道image_tag方法,但为什么?

我没有发现问题。

你能帮帮我吗?)

非常感谢。

1 个答案:

答案 0 :(得分:1)

不要在本地var中传递image_tag的结果,而是尝试将@userView作为本地传递,然后在shared/cadre中使用该本地来呈现图像标记:

<%= render :partial => 'shared/cadre', :locals => {:style => '', :modif => modif, :title => 'AVATAR', :width => 200, :userView => @userView } -%>

替换

<%= display %>

中的部分

<%= image_tag(userView.GetAvatar, :class => 'ie200', :style => 'max-height: 200px; max-width: 200px;') %>