Colin Law wrote:
> On 21 March 2010 15:25, Jagmit Gabba <lists@ruby-forum.com> wrote:
>> � � �flash[:notice] = "Please Login to view this page, or Register if
>> flash message is displayed.
>>
>> When the user is logged in, i want it to redirect the "user/register"
>> and "user/login" to the "user/index", and if they are NOT logged in,
>> they can view them. I have done this with the IF command in my menu but
>> physically they can type the address aka user/register or user/login and
>> view them again.
>
> You have already shown us how you redirect from index to login if the
> user is not logged in. You are asking how to redirect from register
> and login if not logged in. Just use basically the same technique but
> the test will be the the other way round ('if' instead of 'unless').
>
> Colin
Thank you very much Colin,
Simple code:
if session[:user_id]
flash[:notice] = "Already registed and logged in! You cannot view
the register or login!"
redirect_to :action => :index
end
end
Thank you for making me understand :D
--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment