Class: Thredded::MessageboardsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/thredded/messageboards_controller.rb

Instance Method Summary collapse

Methods included from UrlsHelper

#delete_post_path, #edit_post_path, #edit_preferences_path, #edit_preferences_url, #mark_unread_path, #permalink_path, #post_path, #post_url, #quote_post_path, #search_path, #send_private_message_path, #topic_path, #topic_url, #unread_topics_path, #user_path

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
# File 'app/controllers/thredded/messageboards_controller.rb', line 22

def create
  @new_messageboard = Thredded::Messageboard.new(messageboard_params)
  authorize_creating @new_messageboard
  if Thredded::CreateMessageboard.new(@new_messageboard, thredded_current_user).run
    redirect_to root_path
  else
    render :new
  end
end

#destroyObject



47
48
49
50
51
52
# File 'app/controllers/thredded/messageboards_controller.rb', line 47

def destroy
  @messageboard = Thredded::Messageboard.friendly_find!(params[:id])
  authorize @messageboard, :destroy?
  @messageboard.destroy!
  redirect_to root_path, notice: t('thredded.messageboard.deleted_notice')
end

#editObject



32
33
34
35
# File 'app/controllers/thredded/messageboards_controller.rb', line 32

def edit
  @messageboard = Thredded::Messageboard.friendly_find!(params[:id])
  authorize @messageboard, :update?
end

#indexObject



10
11
12
13
14
15
# File 'app/controllers/thredded/messageboards_controller.rb', line 10

def index
  @groups = Thredded::MessageboardGroupView.grouped(
    policy_scope(Thredded::Messageboard.all),
    user: thredded_current_user
  )
end

#newObject



17
18
19
20
# File 'app/controllers/thredded/messageboards_controller.rb', line 17

def new
  @new_messageboard = Thredded::Messageboard.new
  authorize_creating @new_messageboard
end

#updateObject



37
38
39
40
41
42
43
44
45
# File 'app/controllers/thredded/messageboards_controller.rb', line 37

def update
  @messageboard = Thredded::Messageboard.friendly_find!(params[:id])
  authorize @messageboard, :update?
  if @messageboard.update(messageboard_params)
    redirect_to messageboard_topics_path(@messageboard), notice: I18n.t('thredded.messageboard.updated_notice')
  else
    render :edit
  end
end