Class: TopicsController
Instance Method Summary
collapse
#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
#get_matching_ui_locale, #get_sorted_langs_from_accept_header, #get_valid_lang_from_accept_header, #set_locale
#login_by_token, #update_last_seen_at
Instance Method Details
#create ⇒ Object
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
76
77
|
# File 'app/controllers/topics_controller.rb', line 50
def create
@topic = @forum.topics.new(topic_params)
assign_protected
@post = @topic.sb_posts.first
if (!@post.nil?)
@post.user = current_user
end
@topic.tag_list = params[:tag_list] || ''
if !@topic.save
respond_to do |format|
format.html {
render :action => 'new' and return
}
end
else
respond_to do |format|
format.html {
redirect_to forum_topic_path(@forum, @topic)
}
format.xml {
head :created, :location => forum_topic_url(:forum_id => @forum, :id => @topic, :format => :xml)
}
end
end
end
|
#destroy ⇒ Object
89
90
91
92
93
94
95
96
|
# File 'app/controllers/topics_controller.rb', line 89
def destroy
@topic.destroy
flash[:notice] = :topic_deleted.l_with_args(:topic => CGI::escapeHTML(@topic.title))
respond_to do |format|
format.html { redirect_to forum_path(@forum) }
format.xml { head 200 }
end
end
|
#index ⇒ Object
9
10
11
12
13
14
15
16
17
18
|
# File 'app/controllers/topics_controller.rb', line 9
def index
@forum = Forum.find(params[:forum_id])
respond_to do |format|
format.html { redirect_to forum_path(params[:forum_id]) }
format.xml do
@topics = @forum.topics.order('sticky desc, replied_at desc').limit(25)
render :xml => @topics.to_xml
end
end
end
|
#new ⇒ Object
20
21
22
23
|
# File 'app/controllers/topics_controller.rb', line 20
def new
@topic = Topic.new
@topic.sb_posts.build
end
|
#show ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'app/controllers/topics_controller.rb', line 25
def show
respond_to do |format|
format.html do
current_user.update_last_seen_at if logged_in?
(session[:topics] ||= {})[@topic.id] = Time.now.utc if logged_in?
@topic.hit! unless logged_in? and @topic.user == current_user
@posts = @topic.sb_posts.recent.includes(:user).page(params[:page]).per(25)
@voices = @posts.map(&:user).compact.uniq
@post = SbPost.new(params[:post])
end
format.xml do
render :xml => @topic.to_xml
end
format. do
@posts = @topic.sb_posts.recent.limit(25)
render :action => 'show', :layout => false, :formats => [:xml]
end
end
end
|
#update ⇒ Object
79
80
81
82
83
84
85
86
87
|
# File 'app/controllers/topics_controller.rb', line 79
def update
assign_protected
@topic.tag_list = params[:tag_list] || ''
@topic.update_attributes!(topic_params)
respond_to do |format|
format.html { redirect_to forum_topic_path(@forum, @topic) }
format.xml { head 200 }
end
end
|