class Admin::SnippetsController < ApplicationController layout "admin" def index @snippets = Snippet.all end def show @snippet = Snippet.find(params[:id]) redirect_to "/#{@snippet.name}" end def new @snippet = Snippet.new if params[:menu] @snippet.name = "#{params[:menu]}_nav" lis = Page.find(:all, :conditions => { :parent_page_id => params[:menu], :is_published => true }, :order => "position" ).map do |page| if page.external_link.blank? "
  • #{page.name}
  • \n" else "
  • #{page.name}
  • \n" end end VALID_LOCALES.each do |locale| @snippet.write_attribute( "content_#{locale}", "" ) end end end def edit @snippet = Snippet.find(params[:id]) end def create @snippet = Snippet.new(params[:snippet]) if @snippet.save flash[:notice] = 'Snippet was successfully created.' redirect_to admin_snippets_url else render :action => "new" end end def update @snippet = Snippet.find(params[:id]) if @snippet.update_attributes(params[:snippet]) flash[:notice] = 'Snippet was successfully updated.' redirect_to admin_snippets_url else render :action => "edit" end end def destroy @snippet = Snippet.find(params[:id]) @snippet.destroy redirect_to admin_snippets_url end end