Created
August 1, 2011 11:28
-
-
Save Amitesh/1117971 to your computer and use it in GitHub Desktop.
Upload file from ruby on rails program with paperclip gem
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
| # MyModel Model | |
| class MyModel < ActiveRecord::Base | |
| has_attached_file :my_image, | |
| :styles => { :small_thumb => "50x50", | |
| :medium_thumb => "100x100" | |
| }, | |
| :default_url => "/images/missing/prints/:style.png" | |
| end | |
| # Ruby code to upload/push the image into MyModel Model and create the images of different sizes | |
| my_model_obj = MyModel.new | |
| my_model_obj.my_image = File.open('file/path') | |
| my_model_obj.save! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment