app/controllers/spud/admin/posts_controller.rb in spud_blog-0.6.3 vs app/controllers/spud/admin/posts_controller.rb in spud_blog-0.7.0
- old
+ new
@@ -2,12 +2,12 @@
layout 'spud/admin/post'
respond_to :html, :xml, :json
before_filter :find_post, :only => [:show, :edit, :update, :destroy]
add_breadcrumb 'Blog Posts', :spud_admin_posts_path
-
belongs_to_spud_app :blog_posts
+ cache_sweeper :spud_post_sweeper, :only => [:create, :update, :destroy]
def index
@posts = SpudPost.where(:is_news => false).order('published_at desc').includes(:comments, :author).paginate(:page => params[:page], :per_page => 15)
respond_with @posts
end
@@ -19,11 +19,10 @@
def update
@categories = SpudPostCategory.grouped
if @post.update_attributes(params[:spud_post])
flash[:notice] = 'Post was successfully updated.'
- expire_blog_actions
end
respond_with @post, :location => spud_admin_posts_path
end
def new
@@ -35,19 +34,17 @@
def create
@categories = SpudPostCategory.grouped
@post = SpudPost.new(params[:spud_post])
if @post.save
flash[:notice] = 'Post was successfully created.'
- expire_blog_actions
end
respond_with @post, :location => spud_admin_posts_path
end
def destroy
if @post.destroy
flash[:notice] = 'Post was successfully deleted.'
- expire_blog_actions
end
respond_with @post, :location => spud_admin_posts_path
end
private
@@ -56,13 +53,8 @@
@post = SpudPost.find(params[:id])
if @post.blank?
flash[:error] = "Post not found!"
redirect_to spud_admin_posts_path and return false
end
- end
-
- def expire_blog_actions
- expire_action blog_url
- expire_action blog_post_url(@post.url_name) unless @post.nil?
end
end
\ No newline at end of file