# RJS-Template and link\_to\_remote

**URL:** <https://www.ruby-forum.com/t/rjs-template-and-link-to-remote/172806>\
**Category:** Rails\
**Created:** [July 28, 2009, 12:11pm UTC](https://www.ruby-forum.com/t/rjs-template-and-link-to-remote/172806 "2009-07-28T12:11:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Drrrrrr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b77776/32.png) [@Drrrrrr](https://www.ruby-forum.com/u/Drrrrrr)\
**Post date:** [July 28, 2009, 12:11pm UTC](https://www.ruby-forum.com/t/rjs-template-and-link-to-remote/172806/1 "2009-07-28T12:11:55Z")

</div>

Hi, I am quite new to rails and can’t use any rjs-templates.  
The problem is, that he can’t use/find the methods in that template  
e.g. ‘page’ or ‘replace\_html’. I get an error message on these  
methods.

Here’s what I got so far in my example:

## Controller:

class AjaxTestController \< ApplicationController  
layout ‘application’, :except =\> :say\_hello

def index  
end

def say\_hello  
@message = “Hello World”  
respond\_to do |format|  
format.js  
end  
end

## end

## Layout
\<?xml version="1.0" encoding="UTF-8"?\> Ajax \<%= javascript\_include\_tag :defaults %\> \<%= yield %\> ----
## index.html.erb

# Helloworld#index

\<%= link\_to\_remote “Click”,  
:url =\> {:action =\> “say\_hello”} %\>

## 

…

## say\_hello.rjs

## page.replace\_html ‘message’, @message page.visual\_effect(:highlight, ‘message’, :duration =\> 0.5)

its quite simple but does not work anyway. I don’t guess why it  
behaves like this. If I use the controller for that ajax request,  
everything is ok…it’s just that template thing i can’t fix. Anyone  
got an idea where the problem might be?

---

<div class="post-metadata">

**Author:** ![Drrrrrr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b77776/32.png) [@Drrrrrr](https://www.ruby-forum.com/u/Drrrrrr)\
**Post date:** [July 28, 2009, 12:36pm UTC](https://www.ruby-forum.com/t/rjs-template-and-link-to-remote/172806/2 "2009-07-28T12:36:30Z")

</div>

On Jul 28, 2:47 am, Drrrrrr [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi, I am quite new to rails and can’t use any rjs-templates.  
> The problem is, that he can’t use/find the methods in that template  
> e.g. ‘page’ or ‘replace\_html’. I get an error message on these  
> methods.

What error message ?

Fred

---

<div class="post-metadata">

**Author:** ![Drrrrrr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b77776/32.png) [@Drrrrrr](https://www.ruby-forum.com/u/Drrrrrr)\
**Post date:** [July 28, 2009, 12:52pm UTC](https://www.ruby-forum.com/t/rjs-template-and-link-to-remote/172806/3 "2009-07-28T12:52:18Z")

</div>

That common “undefined local variable or method `ï»¿page’” do you need  
that trace generated?

* * *

## C:/RUBYRA~1/rails\_apps/ajax\_test/app/views/ajax\_test/say\_hello.rjs: 1:in `__instance _exec0' C:/RUBYRA~1/rails_apps/ajax_test/app/views/ajax_test/say_hello.rjs: 1:in `\_run\_rjs\_app47views47ajax\_t est47say\_hello46rjs’ C:/RUBYRA~1/rails\_apps/ajax\_test/app/controllers/ ajax\_test\_controller.rb:9:in `say\_hello’

On Jul 28, 12:35Â pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Drrrrrr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b77776/32.png) [@Drrrrrr](https://www.ruby-forum.com/u/Drrrrrr)\
**Post date:** [July 28, 2009, 1:11pm UTC](https://www.ruby-forum.com/t/rjs-template-and-link-to-remote/172806/4 "2009-07-28T13:11:29Z")

</div>

Getting no error working properly

---

<div class="post-metadata">

**Author:** ![Drrrrrr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b77776/32.png) [@Drrrrrr](https://www.ruby-forum.com/u/Drrrrrr)\
**Post date:** [July 28, 2009, 5:15pm UTC](https://www.ruby-forum.com/t/rjs-template-and-link-to-remote/172806/5 "2009-07-28T17:15:44Z")

</div>

might it be possible that i break anything in my rails? maybe a gem or  
an option turned off?
