Class: HelpCenter::SupportThreadsController
Instance Method Summary
collapse
#is_moderator?, #is_moderator_or_owner?, #page_number, #require_mod_or_author_for_post!, #require_mod_or_author_for_thread!
Instance Method Details
#answered ⇒ Object
11
12
13
14
15
|
# File 'app/controllers/help_center/support_threads_controller.rb', line 11
def answered
@support_threads = SupportThread.solved.sorted.includes(:user, :support_category)
@pagy, @records = pagy(@support_threads)
render action: :index
end
|
#create ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
|
# File 'app/controllers/help_center/support_threads_controller.rb', line 45
def create
@support_thread = current_user.support_threads.new(support_thread_params)
@support_thread.support_posts.each{ |post| post.user_id = current_user.id }
if @support_thread.save
HelpCenter::SupportThreadNotificationJob.perform_later(@support_thread)
redirect_to help_center.support_thread_path(@support_thread)
else
render action: :new
end
end
|
#destroy ⇒ Object
68
69
70
71
|
# File 'app/controllers/help_center/support_threads_controller.rb', line 68
def destroy
@support_thread.destroy
redirect_to help_center.support_category_path(@support_thread.support_category), notice: I18n.t('successfully_deleted')
end
|
#edit ⇒ Object
57
58
|
# File 'app/controllers/help_center/support_threads_controller.rb', line 57
def edit
end
|
#index ⇒ Object
6
7
8
9
|
# File 'app/controllers/help_center/support_threads_controller.rb', line 6
def index
@support_threads = SupportThread.pinned_first.sorted.includes(:user, :support_category)
@pagy, @records = pagy(@support_threads)
end
|
#mine ⇒ Object
23
24
25
26
27
|
# File 'app/controllers/help_center/support_threads_controller.rb', line 23
def mine
@support_threads = SupportThread.where(user: current_user).sorted.includes(:user, :support_category)
@pagy, @records = pagy(@support_threads)
render action: :index
end
|
#new ⇒ Object
40
41
42
43
|
# File 'app/controllers/help_center/support_threads_controller.rb', line 40
def new
@support_thread = SupportThread.new
@support_thread.support_posts.new
end
|
#participating ⇒ Object
29
30
31
32
33
|
# File 'app/controllers/help_center/support_threads_controller.rb', line 29
def participating
@support_threads = SupportThread.includes(:user, :support_category).joins(:support_posts).where(support_posts: { user_id: current_user.id }).distinct(support_posts: :id).sorted
@pagy, @records = pagy(@support_threads)
render action: :index
end
|
#show ⇒ Object
35
36
37
38
|
# File 'app/controllers/help_center/support_threads_controller.rb', line 35
def show
@support_post = SupportPost.new
@support_post.user = current_user
end
|
#unanswered ⇒ Object
17
18
19
20
21
|
# File 'app/controllers/help_center/support_threads_controller.rb', line 17
def unanswered
@support_threads = SupportThread.unsolved.sorted.includes(:user, :support_category)
@pagy, @records = pagy(@support_threads)
render action: :index
end
|
#update ⇒ Object
60
61
62
63
64
65
66
|
# File 'app/controllers/help_center/support_threads_controller.rb', line 60
def update
if @support_thread.update(support_thread_params)
redirect_to help_center.support_thread_path(@support_thread), notice: I18n.t('your_changes_were_saved')
else
render action: :edit
end
end
|