Created
June 25, 2015 17:18
-
-
Save RedSoxFan22/6d2f9cf552fbcc754d80 to your computer and use it in GitHub Desktop.
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
How to do Files on the web 10:25 | |
We are working in the "public" folder | |
if we want to use something in the public folder, go to views/where you want it/html page you want it | |
<%= image_tag "name/png%> | |
all the files are accesible immediately on the root. | |
anything that's in public is available to anyone all the time | |
if there are images that should be seen only when logged in, you put them in the asset pipelime | |
public is where developers (not users) put images | |
files that users can upload: | |
file_field_tag, in views/where you want it/html | |
the form needs to be a mulitpart form 10:41 | |
the form needs to take you to a path | |
now do work in the controller associated with the path | |
how to store the file. if we put it int he db, it will make the db run slower. instead we try to store it on a file system or the Cloud. | |
gem 'paperclip', "~> 4.2" ~> Pessimistic versioning, means give me the version or higher as long as the first number is the same 4.5 is okay, but not 5.0, but not 4.1 | |
paperclip puts things in the public folde. to obfuscate has_attached_file :avatar, {:url => "/system/:hash...etc} 11:59 | |
1. rails g migration AddFile | |
2. in model, has_attached_file :uploaded_file validates_attachment_content_type : uploaded_file, :content_type =>(regex) | |
3. in controller | |
if you do a form_for instead of a form_tag, its slightly different | |
use f.file_field | |
and add it to strong params | |
Amazon S3 | |
EC2 | |
S3: everything is S3 happens in regions. creating buckets 11:50 | |
getting your app to use a bucket, first add gem "aws-sdk", '~> 1.6' | |
tell your app how to use sdk 12:01 | |
puts def S3_credentials in class Family < ActiveRecord:: | |
12:13 what to put in config | |
make the bucket and wait 10 minutes for it to load up. | |
clone, don't fork | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment