Sha256: 5b562e0014bdf720a751d0f7abb2d369ebf812579841e132889f184cf72e10bd
Contents?: true
Size: 796 Bytes
Versions: 9
Compression:
Stored size: 796 Bytes
Contents
class Blog::CommentsController < ApplicationController def create @post = Blog::Post.published.find(params[:post_id]) @comment = @post.comments.new(params[:comment]) @comment.save! respond_to do |f| f.html do flash[:notice] = 'Comment created' redirect_to dated_blog_post_path(@post.year, @post.month, @post.slug) end f.js end rescue ActiveRecord::RecordNotFound respond_to do |f| f.html do flash[:error] = 'Blog Post not found' redirect_to blog_posts_path end f.js do render :nothing => true, :status => 404 end end rescue ActiveRecord::RecordInvalid respond_to do |f| f.html do render 'blog/posts/show' end f.js end end end
Version data entries
9 entries across 9 versions & 1 rubygems