# Remote\_function posting?

**URL:** <https://www.ruby-forum.com/t/remote-function-posting/63055>\
**Category:** Rails\
**Created:** [June 11, 2006, 9:31am UTC](https://www.ruby-forum.com/t/remote-function-posting/63055 "2006-06-11T09:31:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wuher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/5fc32e/32.png) [@Wuher](https://www.ruby-forum.com/u/Wuher)\
**Post date:** [June 11, 2006, 9:31am UTC](https://www.ruby-forum.com/t/remote-function-posting/63055/1 "2006-06-11T09:31:36Z")

</div>

Hi, I’ve noticed that my remote\_function calls are resulting in POST  
requests. As a result, my routes do not apply since it does not  
generate a  
url based on the parameters, but simply posts to the raw url with post  
data.  
I want to make a GET request instead of a POST. How can I do that? Has  
anyone else run into this?

## Thanks, Ryan

View this message in context:  
[http://www.nabble.com/remote\_function-posting--t1768936.html#a4814539](http://www.nabble.com/remote_function-posting--t1768936.html#a4814539)  
Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Wuher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/5fc32e/32.png) [@Wuher](https://www.ruby-forum.com/u/Wuher)\
**Post date:** [June 12, 2006, 4:23am UTC](https://www.ruby-forum.com/t/remote-function-posting/63055/2 "2006-06-12T04:23:54Z")

</div>

On 11/06/2006, at 5:28 PM, Wuher wrote:

> Hi, I’ve noticed that my remote\_function calls are resulting in POST  
> requests. As a result, my routes do not apply since it does not  
> generate a  
> url based on the parameters, but simply posts to the raw url with  
> post data.  
> I want to make a GET request instead of a POST. How can I do  
> that? Has  
> anyone else run into this?

I think you’re confused about something here. Routes are applied to  
POST requests in exactly the same way as GET requests. Can you post  
some example code, and describe what you expect it to be doing and  
what it’s actually doing?

Cheers,

Pete Y.  
[http://9cays.com](http://9cays.com)

---

<div class="post-metadata">

**Author:** ![Wuher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/5fc32e/32.png) [@Wuher](https://www.ruby-forum.com/u/Wuher)\
**Post date:** [June 12, 2006, 4:49am UTC](https://www.ruby-forum.com/t/remote-function-posting/63055/3 "2006-06-12T04:49:24Z")

</div>

here is my route line:

map.connect ‘browse\_content/:library\_id/:album\_id/:page’, :controller =\>  
‘view’, :action =\> ‘browse\_content’,  
:page =\> 1, :requirements =\> { :page =\> /\d{1,}/,  
:album\_id =\>  
/-?\d{1,}/, :library\_id =\> /-?\d{1,}/ }

When it posts without a page variable, it does not set the default to 1  
as  
it should. But when I make a GET request, using my browser manually  
(not an  
ajax request), it DOES set the page default to 1. Also, since it is  
posting, it does not format the url to reflect the :library\_id,  
:album\_id,  
and :page variables. It simply posts to ‘/browse\_content’. Anyway, I  
believe POST requests are NOT cached, but I want these to be cached, so  
I  
feel that a GET request is more appropriate.

## Thanks, Ryan

View this message in context:  
[http://www.nabble.com/remote\_function-posting--t1768936.html#a4822674](http://www.nabble.com/remote_function-posting--t1768936.html#a4822674)  
Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Wuher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/5fc32e/32.png) [@Wuher](https://www.ruby-forum.com/u/Wuher)\
**Post date:** [June 13, 2006, 8:54pm UTC](https://www.ruby-forum.com/t/remote-function-posting/63055/4 "2006-06-13T20:54:33Z")

</div>

Well, there is a lot of code that isn’t relevant, but here is the basic  
setup:

route:

```
map.connect 'browse_content/:library_id/:album_id/:page', 

```

:controller =\>  
‘view’, :action =\> ‘browse\_content’,  
:page =\> 1, :requirements =\> { :page =\> /\d{1,}/,  
:album\_id =\>  
/-?\d{1,}/, :library\_id =\> /-?\d{1,}/ }

def browse\_content  
album\_id= @params[‘album\_id’].to\_i if @params[‘album\_id’]  
library\_id= @params[‘library\_id’].to\_i if @params[‘library\_id’]  
page\_number= @params[‘page’].to\_i

```
is_all_albums= (album_id.nil? or album_id == -1 or album_id == 0)
is_all_photos= (is_all_albums and (library_id.nil? or library_id == 

```

-1))

```
....other code...

if is_all_photos
  render :partial => 'library/browse_all_content', :layout => false
elsif is_all_albums
  render :partial => 'library/browse_content', :layout => false
else
  render :partial => 'album/browse_content', :layout => false
end

```

end

here is the view:

Library ‘\<%=h @library.title %\>’  
  
‘\<%=h @album.title %\>’ by \<%= @library.user.fullname %\>  
  
  
  
Total photos: \<%= @total %\>

\<% if @photo\_pages.page\_count \> 1 %\> Page: \<%= pagination\_links\_remote @photo\_pages %\> \<% end %\>

\<%= photo\_thumb\_list %\>

I’m telling you, I don’t think all this code is relevent, because I get  
an  
error saying that I am trying to do nil.to\_i on the 3rd line of the  
browse\_content method. So I know my ‘page’ parameter is not being set.  
But  
I’ve setup the routes to set page to 1 by default. Again, when I POST  
this  
is a problem, but when I GET, it is not. I really just want to make my  
Ajax  
requests GET instead of POST for this reason and for the fact that GETs  
are  
cached and POSTs are not.

## Thanks, Ryan

View this message in context:  
[http://www.nabble.com/remote\_function-posting--t1768936.html#a4852301](http://www.nabble.com/remote_function-posting--t1768936.html#a4852301)  
Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Wuher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/5fc32e/32.png) [@Wuher](https://www.ruby-forum.com/u/Wuher)\
**Post date:** [June 12, 2006, 6:09am UTC](https://www.ruby-forum.com/t/remote-function-posting/63055/5 "2006-06-12T06:09:09Z")

</div>

On 12/06/2006, at 12:48 PM, Wuher wrote:

> here is my route line:
> 
> map.connect  
> ‘browse\_content/:library\_id/:album\_id/:page’, :controller =\>  
> ‘view’, :action =\> ‘browse\_content’,  
> :page =\> 1, :requirements =\> { :page =\> /\d  
> {1,}/, :album\_id =\>  
> /-?\d{1,}/, :library\_id =\> /-?\d{1,}/ }

Can you post the relevant controller and view code too? I’m still not  
clear on what you’re doing, and a few things you’ve said make me  
think you’ve misunderstood how this stuff is supposed to work.

Pete Y.  
[http://9cays.com](http://9cays.com)
