Class: Inboxes::SpeakersController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/inboxes/speakers_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

Raises:

  • (ActiveRecord::RecordNotFound)


5
6
7
8
9
10
# File 'app/controllers/inboxes/speakers_controller.rb', line 5

def create
  raise ActiveRecord::RecordNotFound unless params[:speaker] && params[:speaker][:user_id]
  @user = User.find(params[:speaker][:user_id])
  flash[:notice] = t("inboxes.speakers.added") if @discussion.add_speaker(@user)
  redirect_to @discussion
end

#destroyObject



12
13
14
15
16
17
# File 'app/controllers/inboxes/speakers_controller.rb', line 12

def destroy
  @speaker = Speaker.find(params[:id])
  @speaker.destroy
  flash[:notice] = @speaker.user == current_user ? t("inboxes.discussions.leaved") : t("inboxes.speakers.removed")
  redirect_to @discussion.speakers.any? && @discussion.can_participate?(current_user) ? @discussion : discussions_url
end