Skip to content

Rails quickstart customized to immediately support bootstrap, paperclip, and a global configuration file.

Notifications You must be signed in to change notification settings

tiwillia/rails-bootstrap-openshift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rails Openshift Template

This is a rails quickstart for openshift with the following extras:

Usage

This is built for Openshift, create an account on Openshift.com, install rhc, and then run the following:

rhc app-create APP_NAME ruby-1.9 mysql-5.1 --from-code https://github.com/tiwillia/rails-bootstrap-openshift.git

For general Openshift usage help, see the Getting Started page

Paperclip Configuration for Openshift

For those looking for just the paperclip configuration example:

Note: This does require the global configuration file, which I have included the code for in config/application.rb below

In Gemfile:

gem 'paperclip'
gem 'rmagick' 

In .openshift/action_hooks/deploy:

STORED_IMAGE_ASSETS="${OPENSHIFT_DATA_DIR}public/images" 
LIVE_IMAGE_ASSETS="${OPENSHIFT_REPO_DIR}public/"

# Ensure the image asset directory exists
if [ ! -d "${STORED_IMAGE_ASSETS}" ]; then
  echo " Creating permanent images directory"
  mkdir -p "${STORED_IMAGE_ASSETS}"
fi

# Ensure the image asset directory exists
if [ ! -d "${LIVE_IMAGE_ASSETS}" ]; then
  echo " Creating live images directory"
  mkdir "${LIVE_IMAGE_ASSETS}"
fi

ln -sf "${STORED_IMAGE_ASSETS}" "${LIVE_IMAGE_ASSETS}"

In config/application.rb:

# This block below adds a global YAML configuration file in config/application.yml
CONFIG = YAML.load(File.read(File.expand_path('../application.yml', __FILE__)))
CONFIG.merge! CONFIG.fetch(Rails.env, {})
CONFIG.symbolize_keys!

# This is required for paperclip to work with openshift
if ENV['OPENSHIFT_DATA_DIR']
  CONFIG[:data_dir] = ENV['OPENSHIFT_DATA_DIR']
end

In config/application.yml:

# data_dir should be defined as the local repo root directory in your development environment
data_dir: "/home/tiwillia/Projects/rails-openshift-bootstrap/"

In your model, have at least:

has_attached_file :photo,
  :url => "/images/:id.:extension",
  :path => "#{CONFIG[:data_dir]}public/images/:id.:extension"

About

Rails quickstart customized to immediately support bootstrap, paperclip, and a global configuration file.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published