Replace IRB with Pry (in your Gemfile) and Byebug with pry-byebug
.
gem 'pry-rails', group: [:development, :test]
gem 'pry-byebug', group: [:development, :test]
# Tasks for managing Unicorn instances of a Rails application. | |
# Compatible with Ruby >= 1.9.2 and Rails >= 2 . | |
# Unicorn signals: http://unicorn.bogomips.org/SIGNALS.html | |
namespace :unicorn do | |
class UnicornPIDError < StandardError; end | |
def rails_env | |
Rails.env |
For reference: http://postgis.net/install
The most reliable way to get PostGIS on OSX is to download and install Postgres.app. Great for development and testing. Do not mix with other installations. Select the extension when prompted.
class Attachment < ActiveRecord::Base | |
mount_uploader :attachment, AttachmentUploader | |
# Associations | |
belongs_to :attached_item, polymorphic: true | |
# Validations | |
validates_presence_of :attachment |
<iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?hl=ru&ie=UTF8&output=embed&q={address}"></iframe> |
# Добавляем репозиторий для oracle java | |
add-apt-repository ppa:webupd8team/java | |
# Добавляем репозиторий для elasticsearch | |
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - | |
echo "deb http://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list | |
# Обновить систему | |
apt-get update && apt-get dist-upgrade -y && apt-get autoremove -y && apt-get clean |
upstream application { | |
server unix:/home/deploy/apps/APPNAME/shared/tmp/sockets/puma.sock fail_timeout=0; | |
} | |
# Optional redirect | |
#server { | |
# listen 80; | |
# server_name www.DOMAIN default; | |
# return 301 $scheme://DOMAIN$request_uri; | |
#} |
# 1. Pause replication | |
sudo -u postgres psql -c 'SELECT pg_xlog_replay_pause();' | |
# 2. Perform backup | |
sudo -u postgres pg_dump -Fc DBNAME > /path/to/backup | |
#3. Resume replication |
SECRET_KEY_BASE=ahsbdjhasbjhdabks # run rake:secret to generate | |
DATABASE_URL=postgres://user:pass@dbhost/database |
#возьмем, например, связь one-to-many и вложенными атрибутами | |
class Gallery < ActiveRecord::Base | |
has_many :images | |
accepts_nested_attributes_for :images | |
end | |
class Image < ActiveRecord::Base | |
belongs_to :gallery, required: true |