# Rjs is either not ignored or not evaluated

**URL:** <https://www.ruby-forum.com/t/rjs-is-either-not-ignored-or-not-evaluated/135633>\
**Category:** Rails\
**Created:** [April 23, 2008, 7:30pm UTC](https://www.ruby-forum.com/t/rjs-is-either-not-ignored-or-not-evaluated/135633 "2008-04-23T19:30:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@ssk](https://www.ruby-forum.com/u/ssk)\
**Post date:** [April 23, 2008, 7:30pm UTC](https://www.ruby-forum.com/t/rjs-is-either-not-ignored-or-not-evaluated/135633/1 "2008-04-23T19:30:42Z")

</div>

Hi,

I’m testing ajax in a restful resource.  
In a non-restful controller, ajax worked fine.  
But in a restful controller, ajax didn’t work as I expected.

I did the following.

1. script/generate scaffold user name:string
2. rake db:migrate
3. In users\_controller.rb, I added one line to the create method’s  
response\_to block.

format.js { render :layout =\> false }

1. In index.html.erb, I added an ajax form.

\<% remote\_form\_for :user, User.new, :url =\> users\_path do |f| %\>  
\<%= f.text\_field :name %\>  
\<%= submit\_tag “Create” %\>  
\<% end %\>

1. I created create.js.rjs and wrote a simple rjs code.

page.alert(“Test”)

When I clicked “Create” button, format.html was executed instead of  
format.js.

So I changed the :url part.  
:url =\> formatted\_users\_path(:js)

Now format.js is called but it displays the JavaScript code on a new  
page.  
It’s supposed to be evaluated, right?

What did I do wrong?

Thanks.  
Sam
