Class: Admin::ModeratorsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/moderators_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#admin_index

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
# File 'app/controllers/admin/moderators_controller.rb', line 13

def create
  @moderator = Moderator.new(params[:moderator])
  if @moderator.save
    flash[:notice] = "Account created!"
    redirect_to admin_moderators_url
  else
    render :action => :new
  end
end

#destroyObject



50
51
52
53
54
55
# File 'app/controllers/admin/moderators_controller.rb', line 50

def destroy
	@moderator = Moderator.find(params[:id])
	@moderator.destroy
	flash[:notice] = "Account deleted!"
	redirect_to admin_moderators_url
end

#editObject



27
28
29
30
31
32
33
34
35
# File 'app/controllers/admin/moderators_controller.rb', line 27

def edit
	if current_moderator != @moderator
 @title = "Moderators"
 @cancel_url = admin_moderators_path
	else
 @title = "Edit Account"
 @cancel_url = admin_dashboard_path
	end
end

#indexObject



5
6
7
# File 'app/controllers/admin/moderators_controller.rb', line 5

def index
	@moderators = Moderator.find(:all, :conditions => ["id != ?", current_moderator.id])
end

#newObject



9
10
11
# File 'app/controllers/admin/moderators_controller.rb', line 9

def new
  @moderator = Moderator.new
end

#showObject



23
24
25
# File 'app/controllers/admin/moderators_controller.rb', line 23

def show
	@moderator = @current_moderator
end

#updateObject



37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/admin/moderators_controller.rb', line 37

def update
  if @moderator.update_attributes(params[:moderator])
    flash[:notice] = "Account updated!"
    if current_moderator != @moderator
    	redirect_to admin_moderators_url
    else
    	redirect_to admin_dashboard_path
	  end
  else
    render :action => :edit
  end
end