Created
March 12, 2012 21:01
-
-
Save pencilcheck/2024665 to your computer and use it in GitHub Desktop.
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 UsersController < ApplicationController | |
before_filter :authenticate_user!, :only => [:edit, :update] | |
respond_to :html, :json | |
def index | |
#@users = User.all | |
return if current_user.nil? | |
@users = current_user | |
respond_with @users | |
end | |
def new | |
@user = User.new | |
end | |
def create | |
@user = User.new(params[:user]) | |
if verify_recaptcha | |
if @user.save | |
Notifier.welcome_email(@user).deliver | |
flash[:notice] = 'Signed up!' | |
cookies[:auth_token] = @user.auth_token | |
respond_with @user, :location => root_url, :notice => 'Signed up!' | |
else | |
render "new" | |
end | |
else | |
flash.now[:error] = 'reCaptcha doesn\'t match, please try again.' | |
render "new" | |
end | |
end | |
def edit | |
@user = User.find(params[:id]) | |
end | |
def update | |
@user = User.find(params[:id]) | |
if @user.update_attributes(params[:user]) | |
flash[:notice] = 'User info was successfully updated.' | |
else | |
flash[:error] = 'User info was not successfully updated.' | |
end | |
respond_with @user, :location => root_url | |
=begin | |
respond_to do |format| | |
if @resumedetail.update_attributes(params[:resumedetail]) | |
format.html { redirect_to @resumedetail, notice: 'Resumedetail was successfully updated.' } | |
format.json { head :ok } | |
else | |
format.html { render action: "edit" } | |
format.json { render json: @resumedetail.errors, status: :unprocessable_entity } | |
end | |
end | |
=end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment