forked from maccman/holla
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers_controller.rb
More file actions
70 lines (56 loc) · 1.42 KB
/
Copy pathusers_controller.rb
File metadata and controls
70 lines (56 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class UsersController < ApplicationController
before_filter :require_user, :except => [:new, :create, :avatar]
before_filter :find_user, :only => [:current, :edit, :update]
respond_to :json, :html
layout "backend"
def index
flash.keep
redirect_to :controller => "ria"
end
def current
respond_with(@user) do |wants|
wants.html { render :action => "edit" }
end
end
def new
@user = current_user || User.new
end
def create
@user = User.new(params[:user])
@user.save!
UserSession.create(@user)
flash[:notice] = "Thanks for signing up!"
redirect_back_or_default :action => "index"
rescue ActiveRecord::RecordInvalid
render :action => :new
end
def edit
end
def show
@user = User.find(params[:id])
respond_with(@user) do |wants|
wants.html { render :action => "edit" }
end
end
def update
@user.update_attributes!(params[:user])
flash[:notice] = "Successfully updated"
# For users signing up using user_credentials
UserSession.create(@user)
redirect_to :action => "edit"
rescue ActiveRecord::RecordInvalid
render :action => :edit
end
def avatar
@user = User.find(params[:id])
redirect_to @user.gravatar_url
end
private
def find_user
@user = current_user
end
# For AuthLogic single_access
def single_access_allowed?
true
end
end