Class: Headstart::UsersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/headstart/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/headstart/users_controller.rb', line 39

def create
  @user = ::User.new params[:user]
  @user.email.downcase! if @user.email.present?
  if @user.save
    (@user)
    flash[:notice] = 'You have successfully signed up.'
    redirect_back_or(url_after_create)
  else
    render :template => 'users/new'
  end
end

#editObject



51
52
53
54
55
56
57
# File 'app/controllers/headstart/users_controller.rb', line 51

def edit
  @user = current_user
  if !@user.email_confirmed?
    flash[:notice] = 'Your account has not been confirmed yet. Please confirm using the link in the Welcome email sent to you. Click <a href="/resend_welcome_email">here</a> to resend confirmation email.'
  end
  render :template => 'users/edit'
end

#facebook_removeObject



19
20
21
22
23
24
25
26
27
# File 'app/controllers/headstart/users_controller.rb', line 19

def facebook_remove
  @fb_uid = params[:fb_sig_user] 
  if @fb_uid.present?
    # From here on it will be app specific -- given the facebook uid, destroy the user, like... 
    @user = User.find_by_facebook_uid(@fb_uid)
    @user.update_attribute(:facebook_removed, Time.now) if @user 
  end
  render :nothing => true; return 
end

#newObject



34
35
36
37
# File 'app/controllers/headstart/users_controller.rb', line 34

def new
  @user = ::User.new(params[:user])
  render :template => 'users/new'
end

#resend_welcome_emailObject



12
13
14
15
16
17
# File 'app/controllers/headstart/users_controller.rb', line 12

def resend_welcome_email
  HeadstartMailer.deliver_welcome(current_user)
  flash[:notice] = 'Your confirmation email has been resent.'
  @user = current_user
  render :template => 'users/edit'
end

#showObject



29
30
31
32
# File 'app/controllers/headstart/users_controller.rb', line 29

def show
  @user = current_user
  render :template => 'users/show'
end

#updateObject



59
60
61
62
63
64
65
66
67
68
# File 'app/controllers/headstart/users_controller.rb', line 59

def update
  @user = current_user
  @user.email.downcase! if @user.email.present?
  if @user.update_attributes(params[:user])
    flash[:success] = 'Your profile has been updated.'
    redirect_back_or(user_path(@user))
  else
    render :template => 'users/edit'
  end
end