Class: TopicsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- TopicsController
- Defined in:
- lib/generators/squeezer/templates/app/controllers/topics_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/generators/squeezer/templates/app/controllers/topics_controller.rb', line 17 def create @topic = Topic.new(params[:topic]) @topic=Comment.add_comment(@topic) Comment.add_post(@topic.comment.id,params[:post][:body]) flash[:notice]="Listo!" redirect_to @topic end |
#destroy ⇒ Object
40 41 42 43 44 45 |
# File 'lib/generators/squeezer/templates/app/controllers/topics_controller.rb', line 40 def destroy @topic = Topic.find(params[:id]) @topic.destroy flash[:notice] = "Successfully destroyed topic." redirect_to topics_url end |
#edit ⇒ Object
26 27 28 |
# File 'lib/generators/squeezer/templates/app/controllers/topics_controller.rb', line 26 def edit @topic = Topic.find(params[:id]) end |
#index ⇒ Object
2 3 4 |
# File 'lib/generators/squeezer/templates/app/controllers/topics_controller.rb', line 2 def index @topics = Topic.all end |
#new ⇒ Object
11 12 13 14 15 |
# File 'lib/generators/squeezer/templates/app/controllers/topics_controller.rb', line 11 def new @topic = Topic.new @topic.forum_id=params[:id] @post = Post.new end |
#show ⇒ Object
6 7 8 9 |
# File 'lib/generators/squeezer/templates/app/controllers/topics_controller.rb', line 6 def show @topic = Topic.find(params[:id]) Comment.posts(@topic) end |
#update ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/generators/squeezer/templates/app/controllers/topics_controller.rb', line 30 def update @topic = Topic.find(params[:id]) if @topic.update_attributes(params[:topic]) flash[:notice] = "Successfully updated topic." redirect_to @topic else render :action => 'edit' end end |