2015-08-20 13:43:12 -04:00
|
|
|
require_dependency 'embedding'
|
|
|
|
|
2015-08-18 17:15:46 -04:00
|
|
|
class Admin::EmbeddingController < Admin::AdminController
|
|
|
|
|
|
|
|
before_filter :ensure_logged_in, :ensure_staff, :fetch_embedding
|
|
|
|
|
|
|
|
def show
|
|
|
|
render_serialized(@embedding, EmbeddingSerializer, root: 'embedding', rest_serializer: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2015-08-20 13:43:12 -04:00
|
|
|
Embedding.settings.each do |s|
|
|
|
|
@embedding.send("#{s}=", params[:embedding][s])
|
|
|
|
end
|
|
|
|
|
|
|
|
if @embedding.save
|
|
|
|
fetch_embedding
|
|
|
|
render_serialized(@embedding, EmbeddingSerializer, root: 'embedding', rest_serializer: true)
|
|
|
|
else
|
|
|
|
render_json_error(@embedding)
|
|
|
|
end
|
2015-08-18 17:15:46 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def fetch_embedding
|
2015-08-20 13:43:12 -04:00
|
|
|
@embedding = Embedding.find
|
2015-08-18 17:15:46 -04:00
|
|
|
end
|
|
|
|
end
|