Class: ForumsController

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

Instance Method Summary collapse

Methods inherited from BaseController

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

Methods included from BaseHelper

#add_friend_link, #ajax_spinner_for, #avatar_for, #block_to_partial, #box, #city_cloud, #clippings_link, #commentable_url, #container_title, #excerpt_with_jump, #flash_class, #forum_page?, #is_current_user_and_featured?, #jumbotron, #last_active, #more_comments_links, #page_title, #paginating_links, #possesive, #profile_completeness, #render_jumbotron, #render_widgets, #rounded, #search_posts_title, #search_user_posts_path, #show_footer_content?, #tag_auto_complete_field, #time_ago_in_words, #time_ago_in_words_or_date, #tiny_mce_init_if_needed, #tiny_mce_js, #topnav_tab, #truncate_words, #truncate_words_with_highlight, #widget

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


36
37
38
39
40
41
42
43
44
# File 'app/controllers/forums_controller.rb', line 36

def create
  @forum = Forum.new(forum_params)
  @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


60
61
62
63
64
65
66
67
# File 'app/controllers/forums_controller.rb', line 60

def destroy
  @forum = Forum.find(params[:id])
  @forum.destroy
  respond_to do |format|
    format.html { redirect_to forums_path }
    format.xml  { head 200 }
  end
end

#editObject


46
47
48
# File 'app/controllers/forums_controller.rb', line 46

def edit
  @forum = Forum.find(params[:id])
end

#indexObject


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

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

#newObject


32
33
34
# File 'app/controllers/forums_controller.rb', line 32

def new
  @forum = Forum.new
end

#showObject


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

def show
  @forum = Forum.find(params[:id])
  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


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

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