Rails 3 & Devise: Error when logout -


problem solved

klaustopher answer fixed problem.


the problem can't logout when have <%= current_user.email %> or <%= current_user.username$> in layouts/application.html.erb

when delete line out of application.html.erb, able logout without errors. i've searched on google not find problem.

my application.html.erb:

<!doctype html> <html id="html">  <head> <title><%= content_for?(:title) ? yield(:title) : "contractbeheersysteem" %></title>     <%= stylesheet_link_tag "application", "simple_form", "gegevens", "drop-down-menu",      "table", :media => "all" %>     <%= javascript_include_tag "autocomplete-rails.js" %>     <%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js", "application" %>     <%= javascript_include_tag 'jquery.datatables.min' %>     <%= csrf_meta_tag %>     <%= yield(:head) %> </head>  <body>  <body link="#999" vlink="black" alink="black">    <div id="menu">     <ul id="drop-down-menu">     <li><%= link_to "home page", home_index_path, :class => current_page?(home_index_path) ? "current" : "" %></li>      <li><%= link_to "bedrijfsgegevens", bedrijfsgegevens_path, :id => 'bednav' %>     <ul>         <li><%= link_to "nieuw bedrijf toevoegen", new_bedrijfsgegeven_path %></li>     </ul>      </li>      <li><%= link_to "contactpersonen", contactpersoons_path, :id => 'contanav' %>     <ul>          <li><%= link_to "nieuw contactpersoon", new_contactpersoon_path %></li>      </ul>      </li>     <li><%= link_to "contractgegevens", contractgegevens_path(@contractgegevens), :id => 'contrnav' %>     <ul>          <li><%= link_to "nieuwe contractgegevens", new_contractgegeven_path %></li>      </ul>         <li><%= link_to "contactformulier", contact_index_path, :id => 'formnav' %>        </li>     <% if user_signed_in? %>         <li><%= link_to "my account", users_path(@users) %>         <ul>             <li><%= link_to "uitloggen", destroy_user_session_path, :method => :delete %>             <li><%= link_to "gebruikers", user_registration_path %>         </ul>     <% else %>         <li><%= link_to "inloggen", new_user_session_path %>         <ul>             <li><%= link_to "registreren", new_user_registration_path %>         </ul>     <% end %>     </ul>      <p class="clear_all"></p> </div>  <div id="login"> inlogd als: <%= current_user.username %> </div>  <div id="content">   <hr>     <% flash.each |name, msg| %>     <%= content_tag :div, msg, :id => "flash_#{name}" %>     <% end %>     <%= yield %>  </div>   <div id="footer">     <hr color="#999", width="100%">     <h4>     <b><a href="http://piterjelles.nl">piter jelles</a> &copy; 2012 </b> | <a href="http://rubyonrails.org">ruby on rails </a>      </h4>  </div>   </font>      </body>  </div>  </html> 

note: i'm netherlands there dutch words in application.html.erb

when logged out, current user return nil. calling method on nil return in error

1.9.3p125 :002 >   nil.username nomethoderror: undefined method `username' nil:nilclass 

you have check if current_user returns other nil. can using

<%= current_user.username if current_user %> 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -