Thanks Sergio.
On Jul 30, 6:58 am, "Sergio Cambra .:: entreCables S.L. ::."
<[email protected]> wrote:
> On Miércoles, 29 de Julio de 2009 10:01:28 [email protected] escribió:
>
>
>
> > Hi,
>
> > I have an controller with AS and with a plugin Authlogic to manage
> > login...
>
> > Class MyController < ApplicationController
>
> > before_filter :login_required
>
> > active_scaffold :my_model do |config|
> > ....
> > config.action_links.add 'display_map', :label
> > => :'dialvox.display_map', :inline => true, :page => false, :position
> > => :top
> > ...
> > end
>
> > end
>
> > and in lib/authentification.rb
>
> > ...
> > def login_required
> > unless current_user
> > flash[:error] = "You must be identified to continue"
> > end
> > respond_to do |format|
> > format.html do
> > store_request_uri
> > redirect_to login_url
> > end
> > format.js do
> > store_controller_index
> > render :update do |page|
> > page.redirect_to login_url
> > end
> > end
> > end
> > return false
> > end
> > end
> > ...
>
> > I call my controller to display the AS and later, if I am
> > disconnected, and I clicked on the action link "display map",
> > I have two messages displayed at the begin of my AS :
> > the first is : try { window.location.href = "" }
> > the second is : "You must be identified to continue"
>
> > This happens even for create, update, see action.. in fact, all ajax
> > methods..
> > why I can'tredirectto the login page ?
>
> When an action links makes an AJAX request, if the link has position it waits
> an HTML fragment to include in the page when request is made by AJAX, if link
> has no position (position = false), then it executes the script, so your code
> would work for action links without position.
>
> When action link has position adds the adapter param to the request, so you
> can render the javascript code inside a script tag when params[:adapter]
> exists, and use render :update when params[:adapter] is nil:
>
> def login_required
> unless current_user
> flash[:error] = "You must be identified to continue"
> respond_to do |format|
> format.html do
> store_request_uri
> redirect_to login_url
> end
> format.js do
> store_controller_index
> if params[:adapter].nil?
> render(:update) { |page| page.redirect_to login_url }
> else
> render :inline => "<script
> type='text/javascript'>window.location.href = '#{login_url}'</script>"
> end
> end
> end
> end
> end
>
>
>
> > VIncent
>
> --
> Sergio Cambra .:: entreCables S.L. ::.
> Mariana Pineda 23, 50.018 Zaragoza
> T) 902 021 404 F) 976 52 98 07 E) [email protected]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---