This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_for(@user) do |f| %> | |
<% if @user.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2> | |
<ul> | |
<% @user.errors.full_messages.each do |msg| %> | |
<li><%= msg %></li> | |
<% end %> | |
</ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@user = User.new(params[:user]) | |
respond_to do |format| | |
if @user.save | |
format.html { redirect_to(:users, :notice => 'Registration successfull.') } | |
format.xml { render :xml => @user, :status => :created, :location => @user } | |
else | |
format.html { render :action => "new" } | |
format.xml { render :xml => @user.errors, :status => :unprocessable_entity } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserSession < Authlogic::Session::Base | |
def to_key | |
new_record? ? nil : [ self.send(self.class.primary_key) ] | |
end | |
def persisted? | |
false | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserSessionsController < ApplicationController | |
# GET /user_sessions/new | |
# GET /user_sessions/new.xml | |
def new | |
@user_session = UserSession.new | |
respond_to do |format| | |
format.html # new.html.erb | |
format.xml { render :xml => @user_session } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LoginApp::Application.routes.draw do | |
resources :users, :user_sessions | |
match 'login' => 'user_sessions#new', :as => :login | |
match 'logout' => 'user_sessions#destroy', :as => :logout | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<div id="nav"> | |
<%= link_to "Register", new_user_path%> | | |
<%= link_to "Login", :login %> | |
</div> | |
<%= yield %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Listing users</h1> | |
<p id="notice"><%= notice %></p> | |
<table> | |
<tr> | |
<th>Username</th> | |
<th>Email</th> | |
<th></th> | |
<th></th> | |
<th></th> | |
</tr> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="nav"> | |
<% if current_user %> | |
<%= link_to "Edit Profile", edit_user_path(current_user.id)%> | |
<%= link_to "Logout", :logout%> | |
<% else %> | |
<%= link_to "Register", new_user_path%> | | |
<%= link_to "Login", :login %> | |
<% end %> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
helper_method :current_user | |
private | |
def current_user_session | |
return @current_user_session if defined?(@current_user_session) | |
@current_user_session = UserSession.find |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConversationsController < ApplicationController | |
# GET /conversations | |
# GET /conversations.xml | |
def index | |
@conversations = Conversation.all | |
respond_to do |format| | |
format.html # index.html.erb | |
format.xml { render :xml => @conversations } | |
end |
OlderNewer