# remote\_function problem

**URL:** <https://discuss.rubyonrails.org/t/remote-function-problem/27706>\
**Category:** rubyonrails-talk\
**Created:** [April 8, 2008, 6:37pm UTC](https://discuss.rubyonrails.org/t/remote-function-problem/27706 "2008-04-08T18:37:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [April 8, 2008, 6:37pm UTC](https://discuss.rubyonrails.org/t/remote-function-problem/27706/1 "2008-04-08T18:37:46Z")

</div>

Hi there,

I have the following code in my view:

\<%= check\_box\_tag 'checkopen', 1, params[:checkopen] == '1', &nbsp;&nbsp;: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:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [April 8, 2008, 9:07pm UTC](https://discuss.rubyonrails.org/t/remote-function-problem/27706/2 "2008-04-08T21:07:30Z")

</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?

Does the html/javascript generated look ok ?

Fred

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [April 9, 2008, 7:14am UTC](https://discuss.rubyonrails.org/t/remote-function-problem/27706/3 "2008-04-09T07:14:28Z")

</div>

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

\<%= check\_box\_tag 'checkopen', 1, params[:checkopen] == '1', &nbsp;&nbsp;: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:** ![Julian\_Leviston](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@Julian\_Leviston](https://discuss.rubyonrails.org/u/Julian_Leviston)\
**Post date:** [April 9, 2008, 10:02pm UTC](https://discuss.rubyonrails.org/t/remote-function-problem/27706/4 "2008-04-09T22:02:06Z")

</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/)
