GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
rockastop (author)
Wed Apr 30 18:33:03 -0700 2008
commit  818f0cc9fd46f119d26d034074c145d6ef968c20
tree    56ec073e855e55dc6a47f56e63f0dc996e251be6
parent  65e019892db52a9da2ddc7812801b75d5c077c95
insoshi / app / controllers / topics_controller.rb
100644 75 lines (59 sloc) 1.583 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
class TopicsController < ApplicationController
  
  before_filter :login_required, :except => [:index, :show]
  before_filter :admin_required, :only => :destroy
  before_filter :setup
  
  def index
    @topics = @forum.topics.paginate(:page => params[:page])
 
    respond_to do |format|
      format.html
    end
  end
 
  def show
    @topic = Topic.find(params[:id])
    @posts = @topic.posts
  end
 
  def new
    @topic = Topic.new
 
    respond_to do |format|
      format.html
    end
  end
 
  def edit
    @topic = Topic.find(params[:id])
  end
 
  def create
    @topic = @forum.topics.new(params[:topic].merge(:person => current_person))
 
    respond_to do |format|
      if @topic.save
        flash[:success] = 'Topic was successfully created.'
        format.html { redirect_to forum_topic_path(@forum, @topic) }
      else
        format.html { render :action => "new" }
      end
    end
  end
 
  def update
    @topic = Topic.find(params[:id])
 
    respond_to do |format|
      if @topic.update_attributes(params[:topic])
        flash[:success] = 'Topic was successfully updated.'
        format.html { redirect_to admin_forum_topics_url(@forum) }
      else
        format.html { render :action => "edit" }
      end
    end
  end
 
  def destroy
    @topic = Topic.find(params[:id])
    @topic.destroy
 
    respond_to do |format|
      flash[:success] = 'Topic was successfully destroyed.'
      format.html { redirect_to admin_forum_url(@forum) }
    end
  end
 
  private
  
    def setup
      @forum = Forum.find(params[:forum_id])
      @body = "forum"
    end
end