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, #topic_path, #topic_url, #user_path

Instance Method Details

#createObject



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

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

#editObject



30
31
32
33
# File 'app/controllers/thredded/messageboards_controller.rb', line 30

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

#indexObject



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

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

#newObject



14
15
16
17
18
# File 'app/controllers/thredded/messageboards_controller.rb', line 14

def new
  @messageboard = Thredded::Messageboard.new
  @messageboard_group = Thredded::MessageboardGroup.all
  authorize_creating @messageboard
end

#updateObject



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

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