HighDots Forums  

Doing redirection on a remote call to a function

Ruby On Rails Talk Ruby On Rails programming language mailing list


Discuss Doing redirection on a remote call to a function in the Ruby On Rails Talk forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Charanya Nagarajan
 
Posts: n/a

Default Doing redirection on a remote call to a function - 11-05-2009 , 06:35 AM






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, nchange =>
remote_function( :update => "subcat", :url => { :controller =>
"categories", :action => "get_subcategories"}, osition => "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/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
  #2  
Old   
Denis Haskin
 
Posts: n/a

Default Re: Doing redirection on a remote call to a function - 11-05-2009 , 06:48 AM






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"}, osition => "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


Charanya Nagarajan wrote:
Quote:
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, nchange =
remote_function( :update => "subcat", :url => { :controller =
"categories", :action => "get_subcategories"}, osition => "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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
  #3  
Old   
Charanya Nagarajan
 
Posts: n/a

Default Re: Doing redirection on a remote call to a function - 11-05-2009 , 07:22 AM



Thanks Denis..
this really helped...
--
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.