I'm following along with the Ruby on Rails tutorials as a way to learn RoR faster. (I'm actually learning a lot more from those than the two books I have). Anyway, I'm following them and I'm on the part where you display the users stats on your welcome page after someone logs on. I have added the code as per the tutorial, only altered a little to suit my game:
<%= render :partial => 'users/user_bar' %>
<% if flash[:notice] %>
<%= h flash[:notice] %>
<% end %>
<h1>Welcome To The Game!</h1>
<% if logged_in? %>
<h2><%= @current_user.login %></h2>
<%= u.name rescue nil %>
<ul>Vital Stats:
<li>Level: <strong><%= @current.user.level %></strong></li>
<li>XP: <strong><%= @current.user.xp %></strong></li>
<li>Health: <strong><%= @current.user.health %></strong></li>
<li>Magic: <strong><%= @current.user.magic %></strong></li>
</ul>
<ul>Combat Stats:
<li>Attack: <strong><%= current.user.attack %></strong></li>
<li>Defense: <strong><%= current.user.defense %></strong></li>
<li>Disengage: <strong><%= current.user.disengage %></strong></li>
</ul>
<% end %>
The problem comes with line 8:
[code]
<h2><%= @current_user.login %></h2>
It gives me an error: You have a nil object when you didn't expect it!
I don't know how to fix this, can anyone help?
[/code]