{"id":598,"date":"2022-08-30T15:04:01","date_gmt":"2022-08-30T15:04:01","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/rails-3-devise-error-when-logout-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:04:01","modified_gmt":"2022-08-30T15:04:01","slug":"rails-3-devise-error-when-logout-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/rails-3-devise-error-when-logout-collection-of-common-programming-errors\/","title":{"rendered":"Rails 3 &amp; Devise: Error when logout-Collection of common programming errors"},"content":{"rendered":"<p><strong>Problem solved<\/strong><\/p>\n<p>klaustopher his answer fixed the problem.<\/p>\n<p>The problem is that i can&#8217;t logout when i have or in my layouts\/application.html.erb<\/p>\n<p>When i delete this line out of my application.html.erb, i am able to logout without errors. I&#8217;ve searched on google but could not find anything about this problem.<\/p>\n<p>My application.html.erb:<\/p>\n<pre><code>\n\n\n\n\n     \"all\" %&gt;\n    \n    \n    \n    \n    \n\n\n\n\n  \n\n\n    <\/code><\/pre>\n<ul id=\"drop-down-menu\">\n<li><code>current_page?(home_index_path) ? \"current\" : \"\" %&gt;<\/code><\/li>\n<li><code>'bednav' %&gt;<\/code><\/li>\n<li><code>'contanav' %&gt;<\/code><\/li>\n<li><code>'contrnav' %&gt;<\/code><\/li>\n<li><code>'formnav' %&gt;<\/code><\/li>\n<li>\n<ul>\n<li><code>:delete %&gt;<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre>   \n  <br \/>\n\n\n\nInlogd als: \n\n\n\n  \n    \n     \"flash_#{name}\" %&gt;\n    \n    \n \n\n \n    \n    <\/pre>\n<h4><code><b>Piter Jelles \u00a9 2012<\/b> | Ruby on Rails<\/code><\/h4>\n<pre> \n \n\n     \n \n \n \n<\/pre>\n<p><code>Note: i'm from the netherlands so there are dutch words in my application.html.erb<\/code><\/p>\n<ol>\n<li>\n<p><code>When you are logged out, current user will return <code>nil<\/code>. Calling a method on <code>nil<\/code> will return in an error<\/code><\/p>\n<pre><code>1.9.3p125 :002 &gt;   nil.username\nNoMethodError: undefined method `username' for nil:NilClass\n<\/code><\/pre>\n<p>You have to check if current_user returns something other than nil. You can do this by using<\/p>\n<pre><code>\n<\/code><\/pre>\n<\/li>\n<li>\n<p>you need to check the existence of current_user like: or<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 21:07:04. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Problem solved klaustopher his answer fixed the problem. The problem is that i can&#8217;t logout when i have or in my layouts\/application.html.erb When i delete this line out of my application.html.erb, i am able to logout without errors. I&#8217;ve searched on google but could not find anything about this problem. My application.html.erb: &#8220;all&#8221; %&gt; current_page?(home_index_path) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-598","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/598","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=598"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/598\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}