Some CoffeeScript (verbosely commented for clarity)
# Override Rails handling of confirmation
$.rails.allowAction = (element) ->
# The message is something like "Are you sure?"
message = element.data('confirm')| Tested on: Rails 3.1, Mongoid 2.0.1, pg 0.12.0 gem | |
| Migrate from Mongo to PG | |
| 1. remove mongoid gem | |
| 2. add pg gem | |
| 3. in application.rb re-add ActiveRecord | |
| 4. for all models | |
| - inherit from ActiveRecord::Base | |
| - get rid of Mongoid:Document line | |
| - make migrations and put fields there |
| #Session controller provides a token | |
| #/controllers/api/sessions_controller.rb | |
| class Api::SessionsController < Devise::SessionsController | |
| before_filter :authenticate_user!, :except => [:create] | |
| before_filter :ensure_params_exist, :except => [:destroy] | |
| respond_to :json | |
| def create | |
| resource = User.find_for_database_authentication(:email => params[:user_login][:email]) | |
| return invalid_login_attempt unless resource |
| # sudo ln -s ~/nginx.conf unicorn.conf | |
| upstream app_server { | |
| server unix:/tmp/unicorn_padrino.sock fail_timeout=0; | |
| } | |
| server { | |
| listen 80; | |
| charset utf-8; | |
| server_name db.innshine.com; |
the default index.html does not work well in prodution mode, so do not borther to config that, just delete it and go on.
To put things in production mode, do
rails g scaffold items name:string
rake db:migrate RAILS_ENV=production
rm public/index.html
#change route.rb point root to items#index
rake assets:precompile
sudo service nginx restart
./config/unicorn_init.sh stop
| require "bundler/capistrano" | |
| set :application, "blog" | |
| set :repository, "git@github.com:happypeter/blog.git" | |
| set :scm, :git | |
| # Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none` | |
| set :user, "deployer" | |
| set :deploy_to, "/home/#{user}/#{application}" | |
| set :deploy_via, :remote_cache | |
| set :use_sudo, true |
| // This is a manifest file that'll be compiled into application.js, which will include all the files | |
| // listed below. | |
| // | |
| // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, | |
| // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. | |
| // | |
| // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the | |
| // the compiled file. | |
| // | |
| // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD |
| use your_databasse; | |
| set @attribute_code = 'name'; | |
| set @entity_type_id = '4'; | |
| set @entity_id = '502'; | |
| set @backend_type = | |
| (select backend_type | |
| from eav_attribute | |
| where attribute_code = @attribute_code and |