| Module | ControllerAuthentication |
| In: |
lib/generators/nifty/authentication/templates/controller_authentication.rb
|
This module is included in your application controller which makes several methods available to all controllers and views. Here‘s a common example you might add to your application layout file.
<%% if logged_in? %>
Welcome <%%= current_<%= user_singular_name %>.username %>.
<%%= link_to "Edit profile", edit_current_<%= user_singular_name %>_path %> or
<%%= link_to "Log out", logout_path %>
<%% else %>
<%%= link_to "Sign up", signup_path %> or
<%%= link_to "log in", login_path %>.
<%% end %>
You can also restrict unregistered users from accessing a controller using a before filter. For example.
before_filter :login_required, :except => [:index, :show]