Created
April 28, 2013 07:46
-
-
Save inscapist/5476219 to your computer and use it in GitHub Desktop.
template service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def design | |
@template = Template.find_or_create_by_name(params[:name]) | |
end | |
def design_image | |
@template = Template.find_by_name(params[:name]) | |
render layout: false | |
end | |
def save_design | |
template = Template.find_by_name(params[:name]) | |
template.serialized = request.body | |
status = (template.save)? "success": "failed" | |
render json: {status: status, template: template.as_json} | |
end | |
def save_design_image | |
dir = "#{Rails.root}/public/cards" | |
File.open("#{dir}/#{params[:name]}.png","wb") do |file| | |
file.write(Base64.decode64(params[:png])) | |
end | |
render json: {status: 'success', resp: request.body} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment