Sha256: a8f81dede9c00a52bc467f4405adab95efe920d55da623acffcaf50f634e2223

Contents?: true

Size: 938 Bytes

Versions: 7

Compression:

Stored size: 938 Bytes

Contents

class TopicsController < ApplicationController
  def index
    @topics = Topic.all
  end
  
  def show
    @topic = Topic.find(params[:id])
    Comment.posts(@topic)
  end
  
  def new
    @topic = Topic.new
    @topic.forum_id=params[:id]
    @post = Post.new 
  end
  
  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
  
  def edit
    @topic = Topic.find(params[:id])
  end
  
  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
  
  def destroy
    @topic = Topic.find(params[:id])
    @topic.destroy
    flash[:notice] = "Successfully destroyed topic."
    redirect_to topics_url
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
squeezer-0.2.1 lib/generators/squeezer/templates/app/controllers/topics_controller.rb
squeezer-0.2.0 lib/generators/squeezer/templates/app/controllers/topics_controller.rb
squeezer-0.1.11 lib/generators/squeezer/templates/app/controllers/topics_controller.rb
squeezer-0.1.7 lib/generators/squeezer/templates/app/controllers/topics_controller.rb
squeezer-0.1.6 lib/generators/squeezer/templates/app/controllers/topics_controller.rb
squeezer-0.1.5 lib/generators/squeezer/templates/app/controllers/topics_controller.rb
squeezer-0.1.4 lib/generators/squeezer/templates/app/controllers/topics_controller.rb