Sha256: 7da407824e6a322bcca3a9d541073cfb878e39014862bdded70f1ec65d80ea13
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
require_dependency "landable/api_controller" require_dependency "landable/asset_search_engine" module Landable module Api class AssetsController < ApiController def index search = Landable::AssetSearchEngine.new search_params.merge(ids: params[:ids]) respond_with search.results, meta: search.meta end def show respond_with Asset.find(params[:id]) end def create asset = Asset.new asset_params if original = asset.duplicate_of head :moved_permanently, location: asset_url(original) return end Asset.transaction do asset.author = current_author asset.save! end respond_with asset, status: :created, location: asset_url(asset) end def update asset = Asset.find(params[:id]) asset.update_attributes! asset_params respond_with asset end private def search_params @search_params ||= begin hash = params.permit(search: [:name]) hash[:search] || {} end end def asset_params params.require(:asset).permit(:id, :name, :description, :data, :file) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
landable-1.7.1.rc1 | app/controllers/landable/api/assets_controller.rb |
landable-1.7.0 | app/controllers/landable/api/assets_controller.rb |