Class: Moxie::TopicsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/moxie/topics_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/moxie/topics_controller.rb', line 37

def create
  topic_params = params[:moxie_topic]
  topic_params[:author_id] = current_user.id
  topic_params[:posts_attributes]['0'][:author_id] = current_user.id
        
  @topic = Topic.new( topic_params )
  @forum = Forum.find( params[:moxie_topic][:forum_id] )

  respond_to do |format|
    if @topic.save
      format.html { redirect_to( moxie_forum_path( @topic.forum ), 
                            :notice => 'Topic was successfully created.') }
    else
      format.html { render :new }
    end
  end
end

#newObject



26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/moxie/topics_controller.rb', line 26

def new
  @topic = Topic.new
  @topic.posts.build
  @forum = Forum.find( params[:forum_id] )

  respond_to do |format|
    format.html # new.html.erb
    format.xml  { render :xml => @topic }
  end
end

#showObject



16
17
18
19
20
21
22
23
24
# File 'app/controllers/moxie/topics_controller.rb', line 16

def show
  @topic = Topic.find( params[:id] )
  @post = Post.new

  respond_to do |format|
    format.html # show.html.erb
    format.xml  { render :xml => @topic }
  end
end

#show_postableObject



9
10
11
12
13
14
# File 'app/controllers/moxie/topics_controller.rb', line 9

def show_postable
  @topic = Topic.find( params[:topic_id] )
  @post = Post.new

  render :action => :show
end