Monday, March 24, 2014

Paper Clip Gem

Paper Clip Gem - Review

https://github.com/thoughtbot/paperclip


Paperclip is a gem used for attaching to Rails applications.

Show View
<%= image_tag @user.user_photo.url %>
<%= image_tag @user.user_photo.url(:medium) %>
<%= image_tag @user.user_photo.url(:thumb) %>

Important Finds

:thumb => "200x200#"
The # signifies that this image is going to be saved as as a square on the inside of the photo. This is very useful for user profile pictures.

:medium => "300>x300"
This ensures that the image will have a a width greater than 300 px. 


Profile Pictures

User has_many UserPhotos

- I started by saving a bolean field on the UserPhoto to check if there is a default photo.
- I later found out that it is better to save a link on the user model



How to Link to AWS Account

- It is a a bad idea to save images to the project. Amazon Web Server and Heroku work well together in order to save files at a cheap fast cost.

No comments:

Post a Comment