2009-12-26 60 views
2

我想將我的rails應用程序2.0.2升級到2.3.5。在MySQL發生許多問題之後,我的應用程序遇到了另一個大問題。移植後,Image_tag無法使用rails 2.0.2到2.3.5

這裏的問題是:

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方法,但是爲什麼呢?

我沒有發現問題。

你能幫我嗎:)

非常感謝。

+0

這是否與每個默認的輔助方法?如果是這樣,也許你應該看看你的ApplicationController方法是否存在'helper:all'調用。 – 2009-12-26 12:19:55

+0

這行是我的applicationController的第一行,但任何方法的工作。 – Kiva 2009-12-26 16:42:43

回答

1

不是傳遞的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;') %>