Class: TopicsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- TopicsController
- Defined in:
- lib/generators/forum_monster/templates/controllers/topics_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/generators/forum_monster/templates/controllers/topics_controller.rb', line 12 def create @forum = Forum.find(params[:forum_id]) @topic = @forum.topics.build(params[:topic]) @topic.user = current_user if @topic.save flash[:notice] = "Topic was successfully created." redirect_to topic_url(@topic) else render :action => 'new' end end |
#destroy ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/generators/forum_monster/templates/controllers/topics_controller.rb', line 38 def destroy @topic = Topic.find(params[:id]) if @topic.destroy flash[:notice] = "Topic was deleted successfully." redirect_to forum_url(@topic.forum) end end |
#edit ⇒ Object
25 26 27 |
# File 'lib/generators/forum_monster/templates/controllers/topics_controller.rb', line 25 def edit @topic = Topic.find(params[:id]) end |
#new ⇒ Object
7 8 9 10 |
# File 'lib/generators/forum_monster/templates/controllers/topics_controller.rb', line 7 def new @forum = Forum.find(params[:forum_id]) @topic = Topic.new end |
#show ⇒ Object
2 3 4 5 |
# File 'lib/generators/forum_monster/templates/controllers/topics_controller.rb', line 2 def show @topic = Topic.find(params[:id]) @topic.hit! if @topic end |
#update ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/generators/forum_monster/templates/controllers/topics_controller.rb', line 29 def update @topic = Topic.find(params[:id]) if @topic.update_attributes(params[:topic]) flash[:notice] = "Topic was updated successfully." redirect_to topic_url(@topic) end end |