This script enables you to launch your Rails application in production environment (port:80) with Nginx and Unicorn.
Please make sure that your Gemfile in your rails application includes unicorn.
| module Foo | |
| module Configuration | |
| require 'ostruct' | |
| extend ActiveSupport::Concern | |
| included do | |
| # | |
| end | |
| module ClassMethods |
| # Adapted from https://gist.github.com/1444494 | |
| # Things you need to do before using this lib: | |
| # require 'sinatra/flash' (gem sinatra-flash) | |
| # register Sinatra::Flash | |
| # register Sinatra::AuthInABox | |
| # enable :sessions optionally configuring your favourite sessions settings | |
| # Have a User model, which has the methods self.authenticate(user, pass) and is_admin? | |
| # In your forms (login, signup, etc) make sure you display flash[:errors] |
| .DS_Store | |
| ._* | |
| node_modules/ |
| class ApplicationController < ActionController::Base | |
| # ... | |
| unless Rails.application.config.consider_all_requests_local | |
| rescue_from Exception, with: :render_500 | |
| rescue_from ActionController::RoutingError, with: :render_404 | |
| rescue_from ActionController::UnknownController, with: :render_404 | |
| rescue_from ActionController::UnknownAction, with: :render_404 | |
| rescue_from ActiveRecord::RecordNotFound, with: :render_404 | |
| end |
| /** | |
| * pocketfm | |
| * Pocket-sized File Manager | |
| * Uses plain html to be as simple as possible | |
| * Code is messy, needs revision and needs | |
| * native mv, rm, cp implementations | |
| * Copyright (c) 2011, Christopher Jeffrey (MIT License) | |
| */ | |
| process.title = 'pocketfm'; |
| class AddAttachmentsDataToWrapper < ActiveRecord::Migration | |
| def self.up | |
| add_column :wrappers, :data_file_name, :string | |
| add_column :wrappers, :data_content_type, :string | |
| add_column :wrappers, :data_file_size, :integer | |
| add_column :wrappers, :data_updated_at, :datetime | |
| end | |
| def self.down | |
| remove_column :wrappers, :data_file_name |
| // Set up the events for the form | |
| form | |
| .submit(function() { return form.isValid(settings.validators); }) | |
| // added loading toggle to handle the feedback spinner image (and changed 'beforeSend' to just 'before') | |
| .bind('ajax:before', function() { $("#loading").toggle(); return form.isValid(settings.validators); }) | |
| .bind('ajax:success', function() { $("#loading").toggle(); }) | |
| // Callbacks | |
| .bind('form:validate:after', function(eventData) { clientSideValidations.callbacks.form.after( form, eventData); }) | |
| .bind('form:validate:before', function(eventData) { clientSideValidations.callbacks.form.before(form, eventData); }) |
| #config/initializers/carrierwave.rb | |
| CarrierWave.configure do |config| | |
| if Rails.env.production? or Rails.env.development? | |
| config.storage :cloud_files | |
| config.cloud_files_username = "your_username" | |
| config.cloud_files_api_key = "your_key" | |
| config.cloud_files_container = "test" | |
| config.cloud_files_cdn_host = "c0012345.cdnn.cloudfiles.rackspacecloud.com" | |
| def store_dir |