# Link\_to\_remote, image\_tag, mouseover is this possible?

**URL:** <https://www.ruby-forum.com/t/link-to-remote-image-tag-mouseover-is-this-possible/138540>\
**Category:** Rails\
**Created:** [May 24, 2008, 7:49am UTC](https://www.ruby-forum.com/t/link-to-remote-image-tag-mouseover-is-this-possible/138540 "2008-05-24T07:49:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![freaknasty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a8b319/32.png) [@freaknasty](https://www.ruby-forum.com/u/freaknasty)\
**Post date:** [May 24, 2008, 7:49am UTC](https://www.ruby-forum.com/t/link-to-remote-image-tag-mouseover-is-this-possible/138540/1 "2008-05-24T07:49:19Z")

</div>

Hi guys,

I was wondering if you are able to have a link\_to\_remote, having an  
image\_tag and the link\_to\_remote has a mouseover event that updates a  
div. Does the image\_tag need the mouseover event? I currently have:

\<%= link\_to\_remote(image\_tag(@p\_image.public\_filename(:thumb)), :update  
=\> “big\_pic”, :onmouseover =\> {:action =\> :color\_change, :id =\>  
@p\_image.id})%\>

I get this error on loading my page:

You have a nil object when you didn’t expect it!  
You might have expected an instance of ActiveRecord::Base.  
The error occurred while evaluating nil.[]

I also have this in attempts to solve my problem :  
\<%=image\_tag @p\_image.public\_filename(:thumb), :mouseover=\>  
remote\_function(:update =\> “big\_pic”, :url =\> {:action =\> :color\_change,  
:id =\> @p\_image.id})%\>

The page loads but I get an error using firefox, missing ; before  
statement. Here is the html that is generated:

![Yellow_thumb](https://www.ruby-forum.com/system/0000/0022/yellow_thumb.gif?1211334531)

I just want to have an image that fires a mouseover event that updates a  
larger image. Is there a better way? I hope someone can help me this.

Full trace:  
vendor/rails/actionpack/lib/action\_controller/url\_rewriter.rb:95:in  
`rewrite_url' vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:81:in`rewrite’  
vendor/rails/actionpack/lib/action\_controller/base.rb:616:in `url_for' vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:76:in`send’  
vendor/rails/actionpack/lib/action\_view/helpers/url\_helper.rb:76:in  
`url_for' vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb:461:in`remote\_function’  
vendor/rails/actionpack/lib/action\_view/helpers/prototype\_helper.rb:255:in  
`link_to_remote' app/views/store/show.rhtml:24:in`\_run\_erb\_47app47views47store47show46rhtml’  
app/views/store/show.rhtml:17:in `each' app/views/store/show.rhtml:17:in`\_run\_erb\_47app47views47store47show46rhtml’  
vendor/rails/actionpack/lib/action\_view/base.rb:637:in `send' vendor/rails/actionpack/lib/action_view/base.rb:637:in`compile\_and\_render\_template’  
vendor/rails/actionpack/lib/action\_view/base.rb:365:in `render_template' vendor/rails/actionpack/lib/action_view/base.rb:316:in`render\_file’  
vendor/rails/actionpack/lib/action\_controller/base.rb:1100:in  
`render_for_file' vendor/rails/actionpack/lib/action_controller/base.rb:836:in`render\_with\_no\_layout’  
vendor/rails/actionpack/lib/action\_controller/layout.rb:262:in  
`render_without_benchmark' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in`render’  
C:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in`render’  
vendor/rails/actionpack/lib/action\_controller/base.rb:1153:in  
`default_render' vendor/rails/actionpack/lib/action_controller/base.rb:1159:in`perform\_action\_without\_filters’  
vendor/rails/actionpack/lib/action\_controller/filters.rb:697:in  
`call_filters' vendor/rails/actionpack/lib/action_controller/filters.rb:689:in`perform\_action\_without\_benchmark’  
vendor/rails/actionpack/lib/action\_controller/benchmarking.rb:68:in  
`perform_action_without_rescue' C:/ruby/lib/ruby/1.8/benchmark.rb:293:in`measure’  
vendor/rails/actionpack/lib/action\_controller/benchmarking.rb:68:in  
`perform_action_without_rescue' vendor/rails/actionpack/lib/action_controller/rescue.rb:199:in`perform\_action\_without\_caching’  
vendor/rails/actionpack/lib/action\_controller/caching.rb:678:in  
`perform_action' vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in`cache’  
vendor/rails/activerecord/lib/active\_record/query\_cache.rb:8:in `cache' vendor/rails/actionpack/lib/action_controller/caching.rb:677:in`perform\_action’  
vendor/rails/actionpack/lib/action\_controller/base.rb:524:in `send' vendor/rails/actionpack/lib/action_controller/base.rb:524:in`process\_without\_filters’  
vendor/rails/actionpack/lib/action\_controller/filters.rb:685:in  
`process_without_session_management_support' vendor/rails/actionpack/lib/action_controller/session_management.rb:123:in`process’  
vendor/rails/actionpack/lib/action\_controller/base.rb:388:in `process' vendor/rails/actionpack/lib/action_controller/dispatcher.rb:171:in`handle\_request’  
vendor/rails/actionpack/lib/action\_controller/dispatcher.rb:115:in  
`dispatch' vendor/rails/actionpack/lib/action_controller/dispatcher.rb:126:in`dispatch\_cgi’  
vendor/rails/actionpack/lib/action\_controller/dispatcher.rb:9:in  
`dispatch' vendor/rails/railties/lib/webrick_server.rb:112:in`handle\_dispatch’  
vendor/rails/railties/lib/webrick\_server.rb:78:in `service' C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in`service’  
C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' C:/ruby/lib/ruby/1.8/webrick/server.rb:173:in`start\_thread’  
C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start' C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in`start\_thread’  
C:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start' C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in`each’  
C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start' C:/ruby/lib/ruby/1.8/webrick/server.rb:23:in`start’  
C:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start' vendor/rails/railties/lib/webrick_server.rb:62:in`dispatch’  
vendor/rails/railties/lib/commands/servers/webrick.rb:66  
C:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`require’  
vendor/rails/activesupport/lib/active\_support/dependencies.rb:496:in  
`require' vendor/rails/activesupport/lib/active_support/dependencies.rb:342:in`new\_constants\_in’  
vendor/rails/activesupport/lib/active\_support/dependencies.rb:496:in  
`require' vendor/rails/railties/lib/commands/server.rb:39 C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in`gem\_original\_require’  
C:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require’  
script/server:3

---

<div class="post-metadata">

**Author:** ![freaknasty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/a8b319/32.png) [@freaknasty](https://www.ruby-forum.com/u/freaknasty)\
**Post date:** [June 9, 2008, 8:45pm UTC](https://www.ruby-forum.com/t/link-to-remote-image-tag-mouseover-is-this-possible/138540/2 "2008-06-09T20:45:43Z")

</div>

You could try something like:

```
        <div class="buttons-get-started">
          <%= link_to(image_tag("/images/

```

get\_started\_normal.png", :mouseover =\> ‘/images/  
get\_started\_hover.png’), { :controller =\> ‘user’, :action =\>  
‘register’ }) %\>
