我想升级我的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
的结果,不如尝试将@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;') %>