R – Image_tag doesn’t work after migration rails 2.0.2 to 2.3.5

rubyruby-on-rails

I want to upgrade my rails application 2.0.2 to 2.3.5. After many problem with mysql, I have another big problem with my application.

Here is the problem:

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 doesn't know the image_tag method, but why ?

I don't found the problem.

Can you help me please 🙂

Thanks a lot.

Best Solution

Instead of passing the results of image_tag in a local var, try passing @userView as a local and then in shared/cadre use that local to render the image tag:

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

Replace your

<%= display %>

in the partial with

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