Permalink
Browse files

Auth links and helpers added

  • Loading branch information...
1 parent 2c29fc0 commit a6697136477cde701d430a25887ccb844fa6a69b @nmanzi committed Oct 7, 2011
@@ -1,3 +1,9 @@
class ApplicationController < ActionController::Base
protect_from_forgery
+ helper_method :is_authed?
+
+ private
+ def is_authed?
+ session[:authenticated]
+ end
end
@@ -1,6 +1,6 @@
class SessionsController < ApplicationController
def new
- if session[:authenticated]
+ if is_authed?
redirect_to root_url, :flash => {:info => "Already logged in, you fool."}
end
end
@@ -1,2 +1,5 @@
module ApplicationHelper
+ def is_active?(page)
+ "active" if current_page?(page)
+ end
end
@@ -8,9 +8,21 @@
</head>
<body>
<div class="topbar">
- <div class="fill">
+ <div class="topbar-inner">
<div class="container">
- <a class="brand" href="#">SubbySub</a>
+ <a class="brand" href="/">SubbySub</a>
+ <ul class="nav">
+ <%= content_tag :li, :id => "homelink", :class => is_active?(root_path) do %>
+ <%= link_to "Home", root_path %>
+ <% end %>
+ <% if is_authed? %>
+ <li><%= link_to "Logout", logout_path %></li>
+ <% else %>
+ <%= content_tag :li, :id => "loginlink", :class => is_active?(login_path) do %>
+ <%= link_to "Login", login_path %>
+ <% end %>
+ <% end %>
+ </ul>
</div>
</div>
</div>

0 comments on commit a669713

Please sign in to comment.