Skip to content

Commit 99cfc2a

Browse files
committed
basic user stuff
1 parent 10972de commit 99cfc2a

36 files changed

Lines changed: 382 additions & 341 deletions

app/controllers/application_controller.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,15 @@ class ApplicationController < ActionController::Base
77

88
# Scrub sensitive parameters from your log
99
# filter_parameter_logging :password
10+
helper_method :current_user
11+
12+
private
13+
def current_user_session
14+
return @current_user_session if defined?(@current_user_session)
15+
@current_user_session = UserSession.find
16+
end
17+
18+
def current_user
19+
@current_user = current_user_session && current_user_session.record
20+
end
1021
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class DashboardController < ApplicationController
2+
def index
3+
end
4+
5+
end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class UserSessionsController < ApplicationController
2+
def new
3+
@user_session = UserSession.new
4+
end
5+
6+
def create
7+
@user_session = UserSession.new(params[:user_session])
8+
if @user_session.save
9+
flash[:notice] = "Successfully logged in."
10+
redirect_to root_url
11+
else
12+
render :action => 'new'
13+
end
14+
end
15+
16+
def destroy
17+
@user_session = UserSession.find
18+
@user_session.destroy
19+
flash[:notice] = "Successfully logged out."
20+
redirect_to root_url
21+
end
22+
23+
end
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class UsersController < ApplicationController
2+
def new
3+
@user = User.new
4+
end
5+
6+
def create
7+
@user = User.new(params[:user])
8+
if @user.save
9+
flash[:notice] = "Registration successful."
10+
redirect_to root_url
11+
else
12+
render :action => 'new'
13+
end
14+
end
15+
16+
def edit
17+
@user = current_user
18+
end
19+
20+
def update
21+
@user = current_user
22+
if @user.update_attributes(params[:user])
23+
flash[:notice] = "Successfully updated profile."
24+
redirect_to root_url
25+
else
26+
render :action => "edit"
27+
end
28+
end
29+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class WelcomeController < ApplicationController
2+
def index
3+
end
4+
5+
end

app/helpers/dashboard_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module DashboardHelper
2+
end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module UserSessionsHelper
2+
end

app/helpers/users_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module UsersHelper
2+
end

app/helpers/welcome_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module WelcomeHelper
2+
end

app/models/user.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class User < ActiveRecord::Base
2+
acts_as_authentic
3+
end

0 commit comments

Comments
 (0)