Class: Thredded::PostsController
Instance Method Summary
collapse
Methods included from UrlsHelper
#delete_post_path, #edit_post_path, #edit_preferences_path, #edit_preferences_url, #post_path, #post_url, #search_path, #topic_path, #topic_url, #user_path
Instance Method Details
#create ⇒ Object
11
12
13
14
15
16
17
|
# File 'app/controllers/thredded/posts_controller.rb', line 11
def create
post = parent_topic.posts.build(post_params)
authorize_creating post
post.save!
redirect_to post_path(post, user: thredded_current_user)
end
|
#destroy ⇒ Object
30
31
32
33
34
35
36
|
# File 'app/controllers/thredded/posts_controller.rb', line 30
def destroy
authorize post, :destroy?
post.destroy!
redirect_back fallback_location: topic_url(topic),
notice: I18n.t('thredded.posts.deleted_notice')
end
|
#edit ⇒ Object
19
20
21
|
# File 'app/controllers/thredded/posts_controller.rb', line 19
def edit
authorize post, :update?
end
|
#update ⇒ Object
23
24
25
26
27
28
|
# File 'app/controllers/thredded/posts_controller.rb', line 23
def update
authorize post, :update?
post.update_attributes(post_params.except(:user, :ip))
redirect_to post_path(post, user: thredded_current_user)
end
|