Class: ForumsController

Inherits:
ApplicationController show all
Defined in:
lib/generators/squeezer/templates/app/controllers/forums_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#latests, #site

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
# File 'lib/generators/squeezer/templates/app/controllers/forums_controller.rb', line 15

def create
  if @forum.save
    flash[:notice] = "Successfully created forum."
    redirect_to @forum
  else
    render :action => 'new'
  end
end

#destroyObject



36
37
38
39
40
41
# File 'lib/generators/squeezer/templates/app/controllers/forums_controller.rb', line 36

def destroy
  @forum = Forum.find(params[:id])
  @forum.destroy
  flash[:notice] = "Successfully destroyed forum."
  redirect_to forums_url
end

#editObject



24
25
# File 'lib/generators/squeezer/templates/app/controllers/forums_controller.rb', line 24

def edit
end

#indexObject



3
4
5
# File 'lib/generators/squeezer/templates/app/controllers/forums_controller.rb', line 3

def index
  @forums = Forum.all
end

#newObject



12
13
# File 'lib/generators/squeezer/templates/app/controllers/forums_controller.rb', line 12

def new
end

#showObject



7
8
9
10
# File 'lib/generators/squeezer/templates/app/controllers/forums_controller.rb', line 7

def show
  search = Topic.search(params[:search]).forum_id_equals(@forum.id)
  @topics = search.all.paginate(:per_page => 20, :page => params[:page])    
end

#updateObject



27
28
29
30
31
32
33
34
# File 'lib/generators/squeezer/templates/app/controllers/forums_controller.rb', line 27

def update
  if @forum.update_attributes(params[:forum])
    flash[:notice] = "Successfully updated forum."
    redirect_to @forum
  else
    render :action => 'edit'
  end
end