Class: Inboxes::DiscussionsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/inboxes/discussions_controller.rb', line 28

def create
  @discussion.add_recipient_token current_user.id

  @discussion.messages.each do |m|
    m.discussion = @discussion
    m.user = current_user
  end

  if @discussion.save
    redirect_to @discussion, :notice => t("inboxes.discussions.started")
  else
    render :action => "new"
  end
end

#destroyObject



17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/inboxes/discussions_controller.rb', line 17

def destroy
  @discussion.destroy
  
  flash[:notice] = t("inboxes.discussions.removed")
  begin
    redirect_to :back
  rescue ActionController::RedirectBackError
    redirect_to discussions_url
  end
end

#indexObject



5
6
7
# File 'app/controllers/inboxes/discussions_controller.rb', line 5

def index
  @discussions = current_user.discussions
end

#newObject



13
14
15
# File 'app/controllers/inboxes/discussions_controller.rb', line 13

def new
  @discussion.messages.build
end

#showObject



9
10
11
# File 'app/controllers/inboxes/discussions_controller.rb', line 9

def show
  @discussion.mark_as_read_for(current_user)
end