It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media
This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.
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
sudo -i | |
cd | |
apt-get install build-essential checkinstall && apt-get build-dep imagemagick -y | |
wget http://www.imagemagick.org/download/ImageMagick-6.8.7-7.tar.gz | |
tar xzvf ImageMagick-6.8.9-1.tar.gz | |
cd ImageMagick-6.8.9-1/ | |
./configure --prefix=/opt/imagemagick-6.8 && make | |
checkinstall |
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
require 'aws-sdk' | |
s3 = Aws::S3::Resource.new( | |
region: 'us-east-1', | |
credentials: Aws::InstanceProfileCredentials.new() | |
) | |
bucket = s3.bucket('my-daily-backups') | |
file = (DateTime.now).strftime("%Y.%m.%d-backup") | |
if bucket.object(file).exists? |
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
#Make sure heroku toolbelt and rvm are installed | |
#heroku toolbelt available to download on their site, rvm available via curl | |
\curl -sSL https://get.rvm.io | bash -s stable --ruby | |
rvm use "2.1.1" | |
rvm use --create 2.1.1@project | |
gem install rails | |
#if using postgres (good for heroku) pass argument to 'rails new' | |
rails new project --database=postgresql |
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
stats = Sidekiq::Stats.new | |
stats.queues | |
stats.enqueued | |
stats.processed | |
stats.failed |
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
# this monit config goes in /etc/monit/conf.d | |
check process puma_master | |
with pidfile /data/myapp/current/tmp/puma.pid | |
start program = "/etc/monit/scripts/puma start" | |
stop program = "/etc/monit/scripts/puma stop" | |
group myapp | |
check process puma_worker_0 | |
with pidfile /data/myapp/current/tmp/puma_worker_0.pid |
Do you have spaces in your Windows username?
- Create a new account on Windows without a space.
#Installation
- Download cygwin from http://cygwin.com
- Run setup-(x86|x86_64).exe
- Click next until selecting repo to download packages
- Choose http://cs.vt.edu (gotta go fast), click next
OlderNewer