engine/app/controllers/locomotive/api/snippets_controller.rb

38 lines
943 B
Ruby
Raw Permalink Normal View History

2012-01-23 08:05:50 +00:00
module Locomotive
module Api
class SnippetsController < BaseController
2012-04-25 13:56:38 +00:00
load_and_authorize_resource :class => Locomotive::Snippet
2012-01-23 08:05:50 +00:00
def index
@snippets = current_site.snippets.order_by([[:name, :asc]])
2012-01-23 08:05:50 +00:00
respond_with(@snippets)
end
2012-04-25 13:56:38 +00:00
def show
@snippet = current_site.snippets.find(params[:id])
respond_with @snippet
end
2012-01-23 08:05:50 +00:00
def create
@snippet = current_site.snippets.create(params[:snippet])
respond_with @snippet, :location => main_app.locomotive_api_snippets_url
2012-01-23 08:05:50 +00:00
end
def update
@snippet = current_site.snippets.find(params[:id])
@snippet.update_attributes(params[:snippet])
respond_with @snippet, :location => main_app.locomotive_api_snippets_url
2012-01-23 08:05:50 +00:00
end
2012-04-25 13:56:38 +00:00
def destroy
@snippet = current_site.snippets.find(params[:id])
@snippet.destroy
respond_with @snippet
end
2012-01-23 08:05:50 +00:00
end
end
end