Class: Forem::TopicsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/forem/topics_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_forem_user, #current_user

Instance Method Details

#createObject


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/forem/topics_controller.rb', line 14

def create
  # Association builders are broken in edge Rails atm
  # Hack our way around it
  # TODO: Fix the hack
  @topic = Forem::Topic.new(params[:topic])
  @topic.user = current_user
  @topic.forum_id = params[:forum_id]
  if @topic.save
    flash[:notice] = t("forem.topic.created")
    redirect_to [@forum, @topic]
  else
    flash[:error] = t("forem.topic.not_created")
    render :action => "new"
  end
end

#newObject


9
10
11
12
# File 'app/controllers/forem/topics_controller.rb', line 9

def new
  @topic = @forum.topics.build
  @topic.posts.build
end

#showObject


5
6
7
# File 'app/controllers/forem/topics_controller.rb', line 5

def show
  @topic = @forum.topics.find(params[:id])
end