Created
July 10, 2012 18:06
-
-
Save scottshea/3085211 to your computer and use it in GitHub Desktop.
Activate User Controller
This file contains 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 ActivateUsersController < ApplicationController | |
load_and_authorize_resource :class => false | |
before_filter :populate_roles, :only => [:new_user, :update_user] | |
# GET /users | |
# GET /users.xml | |
def index | |
@users = User.all | |
respond_to do |format| | |
format.html # index.html.erb | |
end | |
end | |
# GET /users/1 | |
# GET /users/1.xml | |
def show | |
@user = User.find(params[:id]) | |
respond_to do |format| | |
format.html # show.html.erb | |
end | |
end | |
# GET /users/new | |
# GET /users/new.xml | |
def new | |
puts "Made it to new" | |
@user = User.new | |
respond_to do |format| | |
format.js | |
end | |
end | |
# GET /users/1/edit | |
def edit | |
@user = User.find(params[:id]) | |
respond_to do |format| | |
format.html do | |
render :partial => "user_form", :user => @user | |
end | |
end | |
end | |
# POST /users | |
# POST /users.xml | |
def create | |
@user = User.new(params[:user]) | |
respond_to do |format| | |
if @user.save | |
format.html { redirect_to(@user, :notice => 'User was successfully created.') } | |
else | |
format.html { render :action => "new" } | |
end | |
end | |
end | |
# PUT /users/1 | |
# PUT /users/1.xml | |
def update | |
@user = User.find(params[:id]) | |
respond_to do |format| | |
if @user.update_attributes(params[:user]) | |
format.html { redirect_to(@user, :notice => 'User was successfully updated.') } | |
else | |
format.html { render :action => "edit" } | |
end | |
end | |
end | |
# DELETE /users/1 | |
# DELETE /users/1.xml | |
def destroy | |
@user = User.find(params[:id]) | |
@user.destroy | |
respond_to do |format| | |
format.html { redirect_to(users_url) } | |
end | |
end | |
def new_user | |
@user = User.new | |
respond_to do |format| | |
format.js | |
end | |
end | |
def update_user | |
@user = User.find(params[:id]) | |
respond_to do |format| | |
format.js | |
end | |
end | |
private | |
def populate_roles | |
@roles = Role.all | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment