Class: ForumsController

Inherits:
BaseController show all
Defined in:
app/controllers/forums_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#advertise, #cache_action?, #css_help, #footer_content, #homepage_features, #plaxo, #rss_site_index, #site_index

Methods included from LocalizedApplication

#get_matching_ui_locale, #get_sorted_langs_from_accept_header, #get_valid_lang_from_accept_header, #set_locale

Methods included from AuthenticatedSystem

#login_by_token, #update_last_seen_at

Instance Method Details

#createObject



32
33
34
35
36
37
38
39
# File 'app/controllers/forums_controller.rb', line 32

def create
  @forum.tag_list = params[:tag_list] || ''
  @forum.save!
  respond_to do |format|
    format.html { redirect_to forums_path }
    format.xml  { head :created, :location => forum_url(:id => @forum, :format => :xml) }
  end
end

#destroyObject



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

def destroy
  @forum.destroy
  respond_to do |format|
    format.html { redirect_to forums_path }
    format.xml  { head 200 }
  end
end

#indexObject



9
10
11
12
13
14
15
# File 'app/controllers/forums_controller.rb', line 9

def index
  @forums = Forum.find(:all, :order => "position")
  respond_to do |format|
    format.html
    format.xml { render :xml => @forums }
  end
end

#showObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/forums_controller.rb', line 17

def show
  respond_to do |format|
    format.html do
      # keep track of when we last viewed this forum for activity indicators
      (session[:forums] ||= {})[@forum.id] = Time.now.utc if logged_in?

      @topics = @forum.topics.includes(:replied_by_user).order('sticky DESC, replied_at DESC').page(params[:page]).per(20)
    end
    
    format.xml do
      render :xml => @forum
    end
  end
end

#updateObject



41
42
43
44
45
46
47
48
# File 'app/controllers/forums_controller.rb', line 41

def update
  @forum.tag_list = params[:tag_list] || ''
  @forum.update_attributes!(params[:forum])
  respond_to do |format|
    format.html { redirect_to forums_path }
    format.xml  { head 200 }
  end
end