app/controllers/spud/admin/snippets_controller.rb in spud_cms-0.9.21 vs app/controllers/spud/admin/snippets_controller.rb in spud_cms-1.0.0.RC1
- old
+ new
@@ -3,11 +3,11 @@
layout '/spud/admin/detail'
add_breadcrumb "Snippets", :spud_admin_snippets_url
before_filter :load_snippet, :only => [:show, :edit, :update, :destroy]
- cache_sweeper :snippet_sweeper, :only => [:update,:destroy,:create]
+ # cache_sweeper :snippet_sweeper, :only => [:update,:destroy,:create]
def index
@snippets = SpudSnippet.site(session[:admin_site]).order(:name).paginate :page => params[:page]
respond_with @snippets
@@ -19,11 +19,11 @@
respond_with @snippet
end
def create
add_breadcrumb "New", :new_spud_admin_snippet_url
- @snippet = SpudSnippet.new(params[:spud_snippet])
+ @snippet = SpudSnippet.new(snippet_params)
@snippet.site_id = session[:admin_site]
@snippet.save
respond_with @snippet, :location => spud_admin_snippets_url
@@ -35,11 +35,11 @@
respond_with @snippet
end
def update
add_breadcrumb "Edit", :edit_spud_admin_snippet_url
- flash[:notice] = "Snippet saved successfully!" if @snippet.update_attributes(params[:spud_snippet])
+ flash[:notice] = "Snippet saved successfully!" if @snippet.update_attributes(snippet_params)
respond_with @snippet, :location => spud_admin_snippets_url
end
def destroy
flash[:notice] = "Snippet removed!" if @snippet.destroy
@@ -55,7 +55,11 @@
redirect_to spud_admin_snippets_url and return false
elsif Spud::Core.multisite_mode_enabled && @snippet.site_id != session[:admin_site]
flash[:warning] = "This snippet is for a different site"
redirect_to spud_admin_snippets_url and return false
end
+ end
+
+ def snippet_params
+ params.require(:spud_snippet).permit(:content, :content_processed, :format, :name)
end
end