# Remote\_function problem

**URL:** <https://www.ruby-forum.com/t/remote-function-problem/134198>\
**Category:** Rails\
**Created:** [April 8, 2008, 8:37pm UTC](https://www.ruby-forum.com/t/remote-function-problem/134198 "2008-04-08T20:37:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sjglazer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@sjglazer](https://www.ruby-forum.com/u/sjglazer)\
**Post date:** [April 8, 2008, 8:37pm UTC](https://www.ruby-forum.com/t/remote-function-problem/134198/1 "2008-04-08T20:37:46Z")

</div>

Hi there,

I have the following code in my view:

\<%= check\_box\_tag ‘checkopen’, 1, params[:checkopen] == ‘1’,  
:onclick =\> remote\_function( :url =\> {:action =\> ‘index’) %\>Open Now

But for some reason whenever the box is checked it calls the create  
action instead of the index action. Any ideas what’s going on?

Thanks,  
steve

---

<div class="post-metadata">

**Author:** ![sjglazer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@sjglazer](https://www.ruby-forum.com/u/sjglazer)\
**Post date:** [April 8, 2008, 11:10pm UTC](https://www.ruby-forum.com/t/remote-function-problem/134198/2 "2008-04-08T23:10:26Z")

</div>

On 8 Apr 2008, at 19:37, Steve G. wrote:

> action instead of the index action. Any ideas what’s going on?

Does the html/javascript generated look ok ?

Fred

---

<div class="post-metadata">

**Author:** ![sjglazer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@sjglazer](https://www.ruby-forum.com/u/sjglazer)\
**Post date:** [April 9, 2008, 9:14am UTC](https://www.ruby-forum.com/t/remote-function-problem/134198/3 "2008-04-09T09:14:28Z")

</div>

You can try passing the get method for the remote call.

\<%= check\_box\_tag ‘checkopen’, 1, params[:checkopen] == ‘1’,  
:onclick =\> remote\_function( :url =\> {:action =\> ‘index’}, :method =\>  
‘get’) %\>Open Now

I am not sure which method should be used. Try with get and post.

And it will be better if u specify the controller name also in the url.

---

<div class="post-metadata">

**Author:** ![sjglazer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@sjglazer](https://www.ruby-forum.com/u/sjglazer)\
**Post date:** [April 10, 2008, 12:03am UTC](https://www.ruby-forum.com/t/remote-function-problem/134198/4 "2008-04-10T00:03:02Z")

</div>

It’s (probably) because he’s using restful routes.

Julian

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)  
VIDEO #3 out NOW!  
[http://sensei.zenunit.com/](http://sensei.zenunit.com/)
