Hi Guys
I have the following questions:
Create the User Hub Page, which would be accessible as index action of
the User controller. Yes, you have already something in this action: if
you made the Week 4 Activity well, you should have displayed a list of
all registered users on that page. But it was only a temporary function:
the system is not supposed to reveal such information. Instead, you will
now create a smart page which will display, for the beginning, the
screen_name and e_mail of the currently logged user.
This exercise consists of three smaller tasks:
1. In the User controller, index action, find the currently logged
user in the database.
2. Using the information prepared in the previous step, display the
information in the corresponding template.
3. Now, modify the main menu of our application. We want the new User
Hub page to substitute the Home Page (site/index) when anyone is logged.
So:
* If nobody is logged, the Home option should link to
site/index, as it does so far.
* If there is a logged user, the same Home option should link
to user/index, and display the User Hub Page.
My user_conttroller.rb file looks like the following:
class UserController < ApplicationController
def register
@title = "Register"
if request.post?
@user = User.new(params[:user])
if @user.save
session[:user_id] = @user.id
flash[:notice] = "User with login #
{@user.screen_name} created successfully!"
redirect_to :action => :index
end
end
end
def index
@title = "Temporary View"
@users = User.find(:all)
@user = User.find_by_id(session[:user_id])
end
end
My Index.html.rb file looks like:
<h1>Users</h1>
<ol>
<p>Currently Logged on User: <%
@user.screen_name %></p>
<p>Currently Logged on User''s email: <%
@user.e_mail %></p>
</ol>
Thanks for all your help in advance.
Cheers
K
Hint: if you need to break the session, or erase the session variable,
just switch your browser off and then on again. All session data will be
then nil.
--
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-/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
-~----------~----~----~----~------~----~------~--~---