Sha256: c51d4bf1387c98b14af2c9323bb06eeb3d18c98c9a6a39be4439768b10562094
Contents?: true
Size: 880 Bytes
Versions: 1
Compression:
Stored size: 880 Bytes
Contents
class CommentsController < ActionController::Base respond_to :html, :xml, :json def index @comments = Comment.where(:article_id => params[:article_id]).all respond_with(@comments) end def new @comment = Comment.new respond_with(@comments) end def create @comment = Comment.new(params[:comment]) if @comment.save redirect_to article_url(params[:article_id]) else render :new end end def edit @comment = Comment.find(params[:id]) respond_with(@comment) end def update @comment = Comment.find( params[:id] ) if @comment.update_attributes(params[:comment]) redirect_to article_url(params[:article_id]) else render :edit end end def destroy @comment = Comment.find( params[:id] ) @comment.destroy redirect_to article_url(params[:article_id]) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
has_comments-0.3.0 | lib/generators/templates/comments_controller.rb |