Created
July 29, 2013 20:24
-
-
Save iamvery/6107481 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| require 'base64' | |
| class SnapshotsController < AuthenticatedController | |
| protect_from_forgery except: :create | |
| def create | |
| chart1 = snapshot.split(',') | |
| image = Base64.decode64(chart1[1]) | |
| file = File.open("/tmp/test.png", 'wb') do|f| | |
| f.write(image) | |
| end | |
| current_user.snapshot = File.open('/tmp/test.png') | |
| current_user.save! | |
| current_user.notify_new_snapshot | |
| head :ok | |
| end | |
| private | |
| def snapshot | |
| params[:snapshot] | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment