engine/app/controllers/locomotive/snippets_controller.rb

41 lines
992 B
Ruby
Raw Normal View History

module Locomotive
class SnippetsController < BaseController
sections 'settings', 'theme_assets'
localized
before_filter :back_to_default_site_locale, :only => %w(new create)
respond_to :json, :only => [:create, :update, :destroy]
def new
@snippet = current_site.snippets.new
respond_with @snippet
end
def create
@snippet = current_site.snippets.create(params[:snippet])
2011-12-05 10:31:34 +00:00
respond_with @snippet, :location => edit_snippet_url(@snippet._id)
end
def edit
@snippet = current_site.snippets.find(params[:id])
respond_with @snippet
end
def update
@snippet = current_site.snippets.find(params[:id])
2011-12-05 12:29:58 +00:00
@snippet.update_attributes(params[:snippet])
2011-12-05 10:31:34 +00:00
respond_with @snippet, :location => edit_snippet_url(@snippet._id)
end
def destroy
@snippet = current_site.snippets.find(params[:id])
2011-12-07 01:09:13 +00:00
@snippet.destroy
respond_with @snippet, :location => theme_assets_url
end
end
end