Class: Formol::TopicsController
Instance Method Summary
collapse
#forum
#last_page_forum_topic_path, #paginated_forum_topic_post_path, #per_page, #topic_last_page_number, #topic_post_page_number
Instance Method Details
#create ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'app/controllers/formol/topics_controller.rb', line 31
def create
formol_authorize!(current_formol_user, :create_topic)
topic.user = current_formol_user
if topic.save
respond_with(topic, :location => [forum, topic])
else
unless topic.poll
topic.build_poll
topic.poll.options.build
end
respond_with(topic, :status => :unprocessable_entity) do |format|
format.html { render :new }
end
end
end
|
#destroy ⇒ Object
68
69
70
71
72
73
74
|
# File 'app/controllers/formol/topics_controller.rb', line 68
def destroy
formol_authorize!(current_formol_user, :destroy_topic)
topic.destroy
respond_with(topic, :location => forum)
end
|
#edit ⇒ Object
50
51
52
53
54
|
# File 'app/controllers/formol/topics_controller.rb', line 50
def edit
formol_authorize!(current_formol_user, :edit_topic, topic)
respond_with(topic)
end
|
#lock ⇒ Object
92
93
94
95
96
97
98
|
# File 'app/controllers/formol/topics_controller.rb', line 92
def lock
formol_authorize!(current_formol_user, :lock_topic)
topic.lock_topic!
respond_with(topic, :location => [forum, topic])
end
|
#new ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/formol/topics_controller.rb', line 18
def new
formol_authorize!(current_formol_user, :create_topic)
topic.posts.build(:register_user_as_subscriber => true)
unless topic.poll
topic.build_poll
topic.poll.options.build
end
respond_with(topic)
end
|
#pin ⇒ Object
76
77
78
79
80
81
82
|
# File 'app/controllers/formol/topics_controller.rb', line 76
def pin
formol_authorize!(current_formol_user, :pin_topic)
topic.pin_topic!
respond_with(topic, :location => [forum, topic])
end
|
#show ⇒ Object
7
8
9
10
11
12
13
14
15
16
|
# File 'app/controllers/formol/topics_controller.rb', line 7
def show
formol_authorize!(current_formol_user, :read_topic)
topic.view!
topic.track_for_user!(current_formol_user)
@posts = topic.posts.ready_for_listing.page(params[:page]).per_page(per_page)
respond_with(topic)
end
|
#unlock ⇒ Object
100
101
102
103
104
105
106
|
# File 'app/controllers/formol/topics_controller.rb', line 100
def unlock
formol_authorize!(current_formol_user, :lock_topic)
topic.unlock_topic!
respond_with(topic, :location => [forum, topic])
end
|
#unpin ⇒ Object
84
85
86
87
88
89
90
|
# File 'app/controllers/formol/topics_controller.rb', line 84
def unpin
formol_authorize!(current_formol_user, :pin_topic)
topic.unpin_topic!
respond_with(topic, :location => [forum, topic])
end
|
#update ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
|
# File 'app/controllers/formol/topics_controller.rb', line 56
def update
formol_authorize!(current_formol_user, :edit_topic, topic)
if topic.update_attributes(params[:topic])
respond_with(topic, :location => [forum, topic])
else
respond_with(topic) do |format|
format.html { render :edit }
end
end
end
|