Ditch the component. Whatever you''re wanting to display with
"myaction", work
it in to the view with partials or as the view itself.
A cleaner way of doing this is by using a before filter in
"mycontroller".
Create an action that will check for the presence of session, and call it as
a before filter.
We''ll call this action "check_for_session". In your
controller, at the top,
put this:
before_filter :check_for_session
Then, define the "check_for_session" action in your controller and
stick your
session-checking logic in there. Simply use redirect_to on failures, which
will send users without sessions to the login page.
Problem solved. When "myaction" is called, the controller will run
check_for_session first. If check_for_session doesn''t see any session,
it
will redirect to the login page. Nice and clean.
On Friday 17 October 2008 01:09:20 Bala Krishnan wrote:> Hi,
> i am using
>
<%=render_component(:controller=>"mycontroller",:action=>"myaction")%>
> on the view.
>
> in my controller i am checking the conditions whether session is there
> or not.
> if session is there i am rendering myaction view, otherwise i am
> redirecting to login controller. but it rendering the login page again
> instead of redirecting.can anybody help me.is it possible to redirect
> for render_component?.
>
> Thanks
> Bala
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---