Remote_function posting?


#1

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
Sent from the RubyOnRails Users forum at Nabble.com.


#2

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


#3

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
Sent from the RubyOnRails Users forum at Nabble.com.


#4

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
Sent from the RubyOnRails Users forum at Nabble.com.


#5

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