# RJS creates JavaScript, which prints to screen instead of ev

**URL:** <https://www.ruby-forum.com/t/rjs-creates-javascript-which-prints-to-screen-instead-of-ev/111516>\
**Category:** Rails\
**Created:** [August 8, 2007, 6:14am UTC](https://www.ruby-forum.com/t/rjs-creates-javascript-which-prints-to-screen-instead-of-ev/111516 "2007-08-08T06:14:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thechak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aeb1de/32.png) [@thechak](https://www.ruby-forum.com/u/thechak)\
**Post date:** [August 8, 2007, 6:14am UTC](https://www.ruby-forum.com/t/rjs-creates-javascript-which-prints-to-screen-instead-of-ev/111516/1 "2007-08-08T06:14:43Z")

</div>

I have a partial named “\_mailing\_list.rhtml” ~

\<% remote\_form\_for(:recipient, :url=\> { :controller =\>  
‘recipients’, :action =\> ‘create’ }) do |f| %\>

Email: \<%= f.text\_field :email\_address, :size =\> 20 -%\> \<%= submit\_tag "Subscribe", :disable\_with =\> "Please wait..." %\>

\<% end %\>

I have a create action in my recipients controller ~

def create  
@recipient = Recipient.new(params[:recipient])  
@recipient.save  
end

I have a create.rjs ~

page[:mailing\_list].reload

The Recipient ActiveRecord correctly updates the database and the RJS  
creates the JavaScript I want, but rather than executing the  
JavaScript, I see it printed to my screen and the URL changed to /  
recipients/create

What am I doing wrong?

Thanks,  
Dan

---

<div class="post-metadata">

**Author:** ![thechak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aeb1de/32.png) [@thechak](https://www.ruby-forum.com/u/thechak)\
**Post date:** [August 8, 2007, 7:07am UTC](https://www.ruby-forum.com/t/rjs-creates-javascript-which-prints-to-screen-instead-of-ev/111516/2 "2007-08-08T07:07:48Z")

</div>

On 8/8/07, Dan C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> \<% end %\>  
> page[:mailing\_list].reload
> 
> The Recipient ActiveRecord correctly updates the database and the RJS  
> creates the JavaScript I want, but rather than executing the  
> JavaScript, I see it printed to my screen and the URL changed to /  
> recipients/create
> 
> What am I doing wrong?
> 
> Thanks,  
> Dan

Have you included the prototype.js library in your layout?

\<%= javascript\_include\_tag :defaults -%\>

HTH  
Daniel

---

<div class="post-metadata">

**Author:** ![thechak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aeb1de/32.png) [@thechak](https://www.ruby-forum.com/u/thechak)\
**Post date:** [August 8, 2007, 7:09am UTC](https://www.ruby-forum.com/t/rjs-creates-javascript-which-prints-to-screen-instead-of-ev/111516/3 "2007-08-08T07:09:48Z")

</div>

Yes, and the source file shows prototype.js, etc. included.

---

<div class="post-metadata">

**Author:** ![thechak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aeb1de/32.png) [@thechak](https://www.ruby-forum.com/u/thechak)\
**Post date:** [August 11, 2007, 3:16am UTC](https://www.ruby-forum.com/t/rjs-creates-javascript-which-prints-to-screen-instead-of-ev/111516/4 "2007-08-11T03:16:53Z")

</div>

Have you updated the default javascript files since you created your  
rails project? I don’t know exactly why that might break your code,  
but I had the same problem you’re describing after I tried to update  
the prototype and scriptaculous files to the latest versions. Once I  
reverted back to what shipped with my version of Rails, my RJS  
templates worked again.
