Class: TopicsController
Instance Method Summary
collapse
#advertise, #cache_action?, #css_help, #footer_content, #homepage_features, #plaxo, #rss_site_index, #site_index
#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(params[:topic])
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.find(:all, :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(params[:topic])
@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!(params[:topic])
respond_to do |format|
format.html { redirect_to forum_topic_path(@forum, @topic) }
format.xml { head 200 }
end
end
|