Topic: Display Hi User after Logged In.

Hi:

I want to display Hi, Username after they log-in. I am still a newbie, and have been trying different variations of code to get it to work: Here is what I have in my application.html.erb

<% if current_user %>
    <%= "hi," + user.username %>
    <%= link_to "Edit Profile", edit_user_path(:current) %> |
    <%= link_to "Logout", logout_path %>
    <% else %>
    <%= link_to "Sign-Up", new_user_path %> |
    <%= link_to "Login", login_path %>
    <% end %>

<%= "hi," + user.username %> this does not seem to work.

my table is called user, and the field is called username. Here is what is in my user_session controller when the user has successfully logged in.

def create
    @user_session = UserSession.new(params[:user_session])
    if @user_session.save
      flash[:notice] = "Successfully logged in."
      redirect_to :back
    else
      render :action => 'new'
    end

I appreciate any help, and thank you in advance.

Last edited by about2flip (2009-11-03 21:07:02)

Re: Display Hi User after Logged In.

What is UserSession?

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Display Hi User after Logged In.

Authlogic's user_session. It's a user_session controller

Last edited by about2flip (2009-11-03 21:57:17)

Re: Display Hi User after Logged In.

You can't have an instance of a controller. It must be a model object.
I was wondering what it contained?
you need to get the currently logged in users name and I was wondering if you already had it in the @user_session object?

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Display Hi User after Logged In.

Here is the user model:

class UsersController < ApplicationController
 
  def new
    @user = User.new
  end
 
  def create
    @user = User.new(params[:user])
    if @user.save
      flash[:notice] = "Registration Successful."
      redirect_to root_url
    else
      render :action => 'new'
    end
  end
 
  def edit
    @user = current_user
  end
 
  def update
    @user = current_user
    if @user.update_attributes(params[:user])
      flash[:notice] = "Successfully updated user."
      redirect_to root_url
    else
      render :action => 'edit'
    end
  end
end

Re: Display Hi User after Logged In.

That's the user controller not the user model.
I don't really know any other way to phrase the question but I'll try.

You have a controller create action that you have shown in your first response

def create
    @user_session = UserSession.new(params[:user_session])
    if @user_session.save
      flash[:notice] = "Successfully logged in."
      redirect_to :back
    else
      render :action => 'new'
    end

You have an erb tag in your view that sais

<%= "hi," + user.username %>

The user variable does not exist and needs to be set up in whatever controller action renders the view.
The only way to do that is to somehow get the user details in that controller action.
In the create action of whatever controller you posted first you will need to have some reference to a unique user in order to make it available to the view.

So can you show me the fields that are available to the UserSession model so that I can tell you how to get the user after you have done the call to @user_session = UserSession.new(params[:user_session])

You will need to look at the database structure, the migration that created the table or a property list if you have a code inspector.

Last edited by jamesw (2009-11-03 22:30:59)

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Display Hi User after Logged In.

There are no fields for UserSession model when I nifty-scaffold, I --skip-model.

class UserSession < Authlogic::Session::Base
end

So here is the migration for user model:
class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.string :username
      t.string :email
      t.string :crypted_password
      t.string :password_salt
      t.string :persistence_token
      t.string :perishable_token
      t.string :from
      t.timestamps
    end
  end
 
  def self.down
    drop_table :users
  end
end
///////////////////////////////////////////////
not sure you need this but this is the form data:

<% form_for @user do |f| %>
 
  <style type="text/css">

  </style>
   
  <%= f.error_messages %>
  <div>
  <p>
    <%= f.label :Username %><br />
    <%= f.text_field :username %>
  </p>
  </div>
  <div>
  <p>
    <%= f.label :Email_Address %><br />
    <%= f.text_field :email %>
  </p>
  </div>
  <div>
  <p>
    <%= f.label :Password %><br />
    <%= f.password_field :password %>
  </p>
  </div>
    <div>
    <p>
    <%= f.label :Confirm_Password %><br />
    <%= f.password_field :password_confirmation %>
  </p>
  </div>
  <div>
  <p>
    <%= f.label :Where_are_you_from%>?<br />
    <%= f.text_field :from %>
  </p>
  </div>
  <div>
  <p><%= f.submit "Submit" %></p></div>
<% end %>
</div>

Re: Display Hi User after Logged In.

There are no fields for UserSession model when I nifty-scaffold, I --skip-model.

UserSession is a class and it's probably a descendant of ActiveRecord but whatever the reality is let's foprget about that for the minuite as your obviously struggling, so lets look at this another way. But I suspect if we don't get to the bottom of this then it's going to come back and bite you.


Can you tell me what controller this action lives in?

def create
    @user_session = UserSession.new(params[:user_session])
    if @user_session.save
      flash[:notice] = "Successfully logged in."
      redirect_to :back
    else
      render :action => 'new'
    end

I suspect that this action is only one of the actions that render the view that you want to put the user name into so can you post the whole controller code for it?
Do you have a log in method? This will be the most likely place that will render the view.

You need to put a line in an action along the lines of @user = User.find(params[:id]) but the user details must already be available in order to log in with so you probably won't need that at all and the info will most likely be available in the UserSession class.

Can you run your application so that the view you want the user name to be displayed in is shown and then post the contents of you your development.log file so I can see what actions and params are being passed around and then I think we might be able to get you your solution plus an explanation of how it all hangs together.

Hang in there because this is really a very simple problem. I'm just struggling to get the info that I need to help you and your log will give that to me.

Your log file is in your_application_root/log/development.log

Last edited by jamesw (2009-11-04 03:09:39)

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Display Hi User after Logged In.

Thanks for the help!!!

user_session controller:

def create
    @user_session = UserSession.new(params[:user_session])
    if @user_session.save
      flash[:notice] = "Successfully logged in."
      redirect_to :back
    else
      render :action => 'new'
    end

Development Log:

Processing UnitController#index (for 127.0.0.1 at 2009-11-04 09:38:50) [GET]
  Parameters: {"action"=>"index", "controller"=>"unit"}
Rendering template within layouts/application
Rendering unit/index
  User Load (0.0ms)   SELECT * FROM "users" WHERE ("users"."id" = '3') LIMIT 1

ActionView::TemplateError (undefined local variable or method `user' for #<ActionView::Base:0x4852efc>) on line #87 of app/views/layouts/application.html.erb:
84: <div id="menuNav">
85: <%= link_to_unless_current "Home", root_url %> |
86: <% if current_user %>
87:     <%= "hi," + user.username %>
88:     <%= link_to "Edit Profile", edit_user_path(:current) %> |
89:     <%= link_to "Logout", logout_path %>
90:     <% else %>

    app/views/layouts/application.html.erb:87
    C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
    C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'

Rendered rescues/_trace (172.0ms)
Rendered rescues/_request_and_response (0.0ms)
Rendering rescues/layout (internal_server_error)


Processing UnitController#index (for 127.0.0.1 at 2009-11-04 09:41:32) [GET]
  Parameters: {"action"=>"index", "controller"=>"unit"}
Rendering template within layouts/application
Rendering unit/index
  User Load (0.0ms)   SELECT * FROM "users" WHERE ("users"."id" = '3') LIMIT 1

ActionView::TemplateError (undefined local variable or method `user' for #<ActionView::Base:0x4676ebc>) on line #87 of app/views/layouts/application.html.erb:
84: <div id="menuNav">
85: <%= link_to_unless_current "Home", root_url %> |
86: <% if current_user %>
87:     <%= "hi," + user.username %>
88:     <%= link_to "Edit Profile", edit_user_path(:current) %> |
89:     <%= link_to "Logout", logout_path %>
90:     <% else %>

    app/views/layouts/application.html.erb:87
    C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
    C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'

Rendered rescues/_trace (125.0ms)
Rendered rescues/_request_and_response (0.0ms)
Rendering rescues/layout (internal_server_error)


Processing UnitController#index (for 127.0.0.1 at 2009-11-04 09:42:08) [GET]
  Parameters: {"action"=>"index", "controller"=>"unit"}
Rendering template within layouts/application
Rendering unit/index
  User Load (0.0ms)   SELECT * FROM "users" WHERE ("users"."id" = '3') LIMIT 1
Completed in 156ms (View: 141, DB: 0) | 200 OK [http://localhost/]


Processing ApplicationController#index (for 127.0.0.1 at 2009-11-04 09:42:09) [GET]

ActionController::RoutingError (No route matches "/stylesheets/.css" with {:method=>:get}):
  C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
  C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'

Rendering rescues/layout (not_found)


Processing UserSessionsController#destroy (for 127.0.0.1 at 2009-11-04 09:42:16) [GET]
  Parameters: {"action"=>"destroy", "controller"=>"user_sessions"}
  User Load (0.0ms)   SELECT * FROM "users" WHERE ("users"."id" = '3') LIMIT 1
Redirected to http://localhost:3000/
Completed in 94ms (DB: 0) | 302 Found [http://localhost/logout]


Processing UnitController#index (for 127.0.0.1 at 2009-11-04 09:42:17) [GET]
  Parameters: {"action"=>"index", "controller"=>"unit"}
Rendering template within layouts/application
Rendering unit/index
Completed in 281ms (View: 281, DB: 0) | 200 OK [http://localhost/]


Processing ApplicationController#index (for 127.0.0.1 at 2009-11-04 09:42:17) [GET]

ActionController::RoutingError (No route matches "/stylesheets/.css" with {:method=>:get}):
  C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
  C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'

Rendering rescues/layout (not_found)


Processing UserSessionsController#new (for 127.0.0.1 at 2009-11-04 09:42:19) [GET]
  Parameters: {"action"=>"new", "controller"=>"user_sessions"}
Rendering template within layouts/application
Rendering user_sessions/new
Completed in 281ms (View: 218, DB: 0) | 200 OK [http://localhost/login]


Processing ApplicationController#index (for 127.0.0.1 at 2009-11-04 09:42:20) [GET]

ActionController::RoutingError (No route matches "/stylesheets/.css" with {:method=>:get}):
  C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
  C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'

Rendering rescues/layout (not_found)


Processing UserSessionsController#create (for 127.0.0.1 at 2009-11-04 09:42:30) [POST]
  Parameters: {"commit"=>"Submit", "user_session"=>{"username"=>"mnusom", "password"=>"[FILTERED]"}, "action"=>"create", "authenticity_token"=>"0MwKgH7+RskSx7qbaSLCrudN5Ohxqqb4antJ2uwmlLY=", "controller"=>"user_sessions"}
  User Load (16.0ms)   SELECT * FROM "users" WHERE (LOWER("users".username) = 'mnusom') LIMIT 1
Redirected to http://localhost:3000/login
Completed in 1500ms (DB: 16) | 302 Found [http://localhost/user_sessions]


Processing UserSessionsController#new (for 127.0.0.1 at 2009-11-04 09:42:31) [GET]
  Parameters: {"action"=>"new", "controller"=>"user_sessions"}
Rendering template within layouts/application
Rendering user_sessions/new
  User Load (0.0ms)   SELECT * FROM "users" WHERE ("users"."id" = '3') LIMIT 1
Completed in 63ms (View: 31, DB: 0) | 200 OK [http://localhost/login]


Processing ApplicationController#index (for 127.0.0.1 at 2009-11-04 09:42:31) [GET]

ActionController::RoutingError (No route matches "/stylesheets/.css" with {:method=>:get}):
  C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
  C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'

Rendering rescues/layout (not_found)

Thanks Again

Re: Display Hi User after Logged In.

A couple of things here

Processing UnitController#index (for 127.0.0.1 at 2009-11-04 09:38:50) [GET]
  Parameters: {"action"=>"index", "controller"=>"unit"}
Rendering template within layouts/application
Rendering unit/index
  User Load (0.0ms)   SELECT * FROM "users" WHERE ("users"."id" = '3') LIMIT 1

ActionView::TemplateError (undefined local variable or method `user' for #<ActionView::Base:0x4852efc>) on line #87 of app/views/layouts/application.html.erb:
84: <div id="menuNav">
85: <%= link_to_unless_current "Home", root_url %> |
86: <% if current_user %>
87:     <%= "hi," + user.username %>
88:     <%= link_to "Edit Profile", edit_user_path(:current) %> |
89:     <%= link_to "Logout", logout_path %>
90:     <% else %>

Processing UnitController#index (for 127.0.0.1 at 2009-11-04 09:38:50) [GET]
  Parameters: {"action"=>"index", "controller"=>"unit"}

Tells me that it is the index action on yout unit_controller.rb that is rendering the view.

The next bit

Rendering unit/index
  User Load (0.0ms)   SELECT * FROM "users" WHERE ("users"."id" = '3') LIMIT 1

Tells me that the user is available already in that action so all you need to do is understand the variable name that is being used in that action and use it in your view

Can you post up the index action on your unit_controller.rb?

I'm not entirely certain of your logic flow as you have create actions on the user happening after this point but that's not really important right now.

One other thing

Processing ApplicationController#index (for 127.0.0.1 at 2009-11-04 09:42:31) [GET]

ActionController::RoutingError (No route matches "/stylesheets/.css" with {:method=>:get}):
  C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
  C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
  C:/Ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'

Rendering rescues/layout (not_found)

Application controller does not normally have an index action. Why is that there?

In your layouts you will have a stylesheet link tag that is pointing to a stylesheet with no name (An empty string somewhere?) You need to either remove that link or give it the name of a valid stylesheet.

Last edited by jamesw (2009-11-04 12:16:53)

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Display Hi User after Logged In.

My unit_controller does not have anything in it but pagetitles. This is the stuff from my application controller:

filter_parameter_logging :password
helper_method :current_user_session, :current_user

private
      def current_user_session
        return @current_user_session if defined?(@current_user_session)
        @current_user_session = UserSession.find
      end

      def current_user
        return @current_user if defined?(@current_user)
        @current_user = current_user_session && current_user_session.user
      end
      
      def require_user
      unless current_user
        store_location
        flash[:notice] = "You must be logged in to access this page"
        redirect_to new_user_session_url
        return false
      end
    end

    def require_no_user
      if current_user
        store_location
        flash[:notice] = "You must be logged out to access this page"
        redirect_to account_url
        return false
      end
    end
   
    def store_location
      session[:return_to] = request.request_uri
    end
   
    def redirect_back_or_default(default)
      redirect_to(session[:return_to] || default)
      session[:return_to] = nil
    end
end

I know about the missing css, I am still designing stuff so I took it out for the moment until I finish. Then I will take the internal sheet and make it external.

Re: Display Hi User after Logged In.

I know about the missing css, I am still designing stuff so I took it out for the moment until I finish. Then I will take the internal sheet and make it external.

OK but that's not the best approach.
Once you deploy your app you will be editing the stylesheet anyway so it's best to get used to working in the same way as you mean to go on.
There is another reason.
Moving the styles out of your view effectively means that you will have to re test every single style elelemrnt again.
Why add work when you can save yourself a lot of time and potential hassel by setting up your style sheets now?

OK, back to your problem

My unit_controller does not have anything in it but pagetitles

And an Index action that I needed to see but having looked at your application controller I can see a before filter that get's you a an instance variable of @current_user.

So all you need to do to solve your problem is to change your view code to use this instance variable.
So change

<% if current_user %>
    <%= "hi," + user.username %>
    <%= link_to "Edit Profile", edit_user_path(:current) %> |
    <%= link_to "Logout", logout_path %>
    <% else %>
    <%= link_to "Sign-Up", new_user_path %> |
    <%= link_to "Login", login_path %>
    <% end %>

to

<% if @current_user %><!-- Notice the @ here -->
    <%= "hi," + @current_user.username %><!-- And this line makes use of the same object -->
    <%= link_to "Edit Profile", edit_user_path(:current) %> |
    <%= link_to "Logout", logout_path %>
<% else %>
    <%= link_to "Sign-Up", new_user_path %> |
    <%= link_to "Login", login_path %>
<% end %>

I've indented you code to make it more readable
The filter in your application controller makes sure that whenever it is appropriate you will have a @current_user object available to any view.

It is this instance variable that should be used for the checks that are needed and it also has the usename property as indicated from your log files.

So the two lines I have changed

<% if @current_user %><!-- Notice the @ here -->
    <%= "hi," + @current_user.username %><!-- And this line makes use of the same object -->

Now use the correct variables.

An explanation of how and why this works for you.

Websites are stateless. Every time you call an action you hit the server and the only information that is available to that action is whatever has been set up in that action or passed in as a param.
The session is a cookie that also allows you to fake out statefullness so you can retain other info.

Your before filter set up various variables s part of every single controller action for every single controller in your application that descends from application_controller, which is in fact every single action.

Therefore all the variables set up in those before filters are always available to every view and controller.

But because you do not pass the params needed for the filters to work in every single view, the data that is needed is stored in the session and therefore gives you some state that you would not otherwise be able to have.
Without the session you would always have to pass the params needed for thise filters.

Hope that makes sense

Last edited by jamesw (2009-11-04 15:08:58)

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Display Hi User after Logged In.

Thanks for the advice on the css. I tried what you told me with the @current_user, and it did not work. So I tried it without the @ and it did work. Thanks for taking the time and effort to helping me out, I appreciate that.

How long have you been programming ROR? What books, tutorials did you follow. I just started learning 2 months now, and it is a lot to take in. Knowing what goes where as far as the language. I am still trying to figure out what goes in the controller, what goes in the model,etc.

Again Thanks.

Re: Display Hi User after Logged In.

Simply Rails 2 by Sitepoint.com is a good beginners book.  http://www.sitepoint.com/books/rails2/

Agile Web Development with Rails 3rd Ed. by pragprog.com is THE standard book for learning Rails and is an excellent resource. http://pragprog.com/titles/rails3/agile … rd-edition

Boo.

Re: Display Hi User after Logged In.

tried it without the @ and it did work

Yeah, I was going to suggest that first as I was curious about why <% if current_user %> hadn't raised an error.
Now I have re-read the application controller code you posted I notice that I mistook helper_method for being a filter. Sorry for misleading you.
I'm still not sure which controller action is calling the view though

The current_user will be a helper method

How long have you been programming ROR? What books, tutorials did you follow. I just started learning 2 months now, and it is a lot to take in. Knowing what goes where as far as the language. I am still trying to figure out what goes in the controller, what goes in the model,etc.

You're most welcome :-)

I've been programming RoR for 8 months now in anger but RoR is my 13th Language.
I've been a proffesional programmer for 19 years at the end of this month.
I did a full time course for a year that taught me how to write COBOL.
I went on to use C and then C++ and 4GL's like Sculptor (On the Apple Mac).
Finally settled on Delphi with some VB which were my main languages for the last 6 years prior to ditching it for RoR which I now use almost exclusively.

It took about 2 months before someone recommended AWDWR.
Coupled with the Programming Ruby book I'm now starting to really understand how it all fits together. But it takes time.

Last edited by jamesw (2009-11-05 15:04:47)

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)