Class: Formol::PostsController
Instance Method Summary
collapse
#topic
#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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/formol/posts_controller.rb', line 24
def create
formol_authorize!(current_formol_user, :create_post, topic)
post(:user => current_formol_user)
if post.save
respond_with(post, :status => :created, :location => last_page_forum_topic_path(topic.forum, post.topic(true), post))
else
respond_with(post, :status => :unprocessable_entity) do |format|
format.html { render :new }
end
end
end
|
#destroy ⇒ Object
57
58
59
60
61
62
63
|
# File 'app/controllers/formol/posts_controller.rb', line 57
def destroy
formol_authorize!(current_formol_user, :destroy_post)
post.destroy
respond_with(post, :location => [topic.forum, topic])
end
|
#edit ⇒ Object
39
40
41
42
43
|
# File 'app/controllers/formol/posts_controller.rb', line 39
def edit
formol_authorize!(current_formol_user, :edit_post, post)
post
end
|
#new ⇒ Object
18
19
20
21
22
|
# File 'app/controllers/formol/posts_controller.rb', line 18
def new
formol_authorize!(current_formol_user, :create_post, topic)
post(:quote_id => params[:quote], :user => current_formol_user)
end
|
#show ⇒ Object
7
8
9
10
11
12
13
14
15
16
|
# File 'app/controllers/formol/posts_controller.rb', line 7
def show
formol_authorize!(current_formol_user, :read_topic)
post
respond_with(post) do |format|
format.html { redirect_to paginated_forum_topic_post_path(post.topic.forum, post.topic, post) }
end
end
|
#update ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
|
# File 'app/controllers/formol/posts_controller.rb', line 45
def update
formol_authorize!(current_formol_user, :edit_post, post)
if post.update_attributes(params[:post])
respond_with(post, :location => paginated_forum_topic_post_path(topic.forum, topic, post))
else
respond_with(post) do |format|
format.html { render :edit }
end
end
end
|