Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Doing redirection on a remote call to a function
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Charanya Nagarajan  
View profile   Translate to Translated (View Original)
 More options 5 Nov, 11:35
From: Charanya Nagarajan <rails-mailing-l...@andreas-s.net>
Date: Thu, 5 Nov 2009 12:35:13 +0100
Local: Thurs 5 Nov 2009 11:35
Subject: Doing redirection on a remote call to a function
Hi All

In my application,i have a form which contains a select box for
"categories"
And when the user selects a category,a remote function is called which
fetches a list of subcategories and populates in another select box on
the form

<div id="categorylist">
<div id="category">Category:<%= collection_select :category, :id,
@categories, :id , :name, {}, {:size => 10, :onchange =>
remote_function( :update => "subcat", :url => { :controller =>
"categories", :action => "get_subcategories"}, :position => "replace",
:with => "'category_id='+this.value" ) } %></div>
</div>
I have a div with id "subcat" on the form.

I also have set a session timeout of 10 mins.
I am getting my page redirected to login page if not the session is
present/timed out.I am doing this by having the function called
"login_required" in the application.rb controller and in all controllers
I am adding
before_filter :login_required

But this is working only in case of Normal Http requests.

In the above case,if the session has expired,and the user is trying to
populate the subcategory list using remote call,I am getting the error
message updated in the div with id subcat .
But I want the page to be redirected to login page,even when there are
remote calls to the function if session has timed out.

I am in need of a solution at the earliest.Kindly help me

Thanks
Charanya
--
Posted via http://www.ruby-forum.com/.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Denis Haskin  
View profile   Translate to Translated (View Original)
 More options 5 Nov, 11:48
From: Denis Haskin <de...@haskinferguson.net>
Date: Thu, 05 Nov 2009 06:48:58 -0500
Local: Thurs 5 Nov 2009 11:48
Subject: Re: [Rails] Doing redirection on a remote call to a function
You can specify Javascript callbacks for the various phases of the
remote call and also for specific response status or status codes (see
the doc for link_to_remote at http://tinyurl.com/s47df ; remote_function
takes the same arguments).

So it might be something like this (off the top of my head):

remote_function( :update => "subcat", :url => { :controller =>
"categories", :action => "get_subcategories"}, :position => "replace",
:with => "'category_id='+this.value", 302 => "handleRedirection(request)" )

where handleRedirection() is a Javascript function you've written to do the redirection (I'm assuming the response Lcation: header is available there, but haven't checked).

hth,

dwh


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Charanya Nagarajan  
View profile   Translate to Translated (View Original)
 More options 5 Nov, 12:22
From: Charanya Nagarajan <rails-mailing-l...@andreas-s.net>
Date: Thu, 5 Nov 2009 13:22:03 +0100
Local: Thurs 5 Nov 2009 12:22
Subject: Re: Doing redirection on a remote call to a function
Thanks Denis..
this really helped...
--
Posted via http://www.ruby-forum.com/.

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google