SSH into Root
$ ssh root@123.123.123.123
Change Root Password
SSH into Root
$ ssh root@123.123.123.123
Change Root Password
require 'mina/bundler' | |
require 'mina/rails' | |
require 'mina/git' | |
require 'mina/rvm' | |
# Usually mina focuses on deploying to one host and the deploy options are therefore simple. | |
# In our case, there is a number of possible servers to deploy to, it is therefore necessary to | |
# specify the host that we are targeting. | |
server = ENV['server'] | |
# Since the same host can have multiple applications running in parallel, it is necessary to |
# lib/tasks/deploy.rake | |
namespace :deploy do | |
desc 'Deploy to staging environment' | |
task :staging do | |
exec 'mina deploy -f config/deploy/staging.rb' | |
end | |
end |
# nginx.conf | |
user nginx; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log; | |
pid /var/run/nginx.pid; | |
timer_resolution 500ms; |
# myapp | |
upstream unicorn_myapp { | |
server unix:/var/rails/myapp/current/tmp/sockets/unicorn.sock fail_timeout=0; | |
} | |
server { | |
server_name myapp.com www.myapp.com; | |
root /var/rails/myapp/current/public; |
require 'rspec/core/rake_task' | |
RSpec::Core::RakeTask.new(:spec) do |t| | |
t.rspec_opts = '--format html --out reports/rspec_results.html' | |
end | |
namespace :rspec_report do | |
desc 'Run all specs and generate RSpec report in HTML' | |
task :html => :spec |
Rails 4 uses asset pipeline to concatenate and minify or compress JavaScript and CSS assets. It creates a default app/assets/stylesheets/application.css file which contains these lines:
/*
*= require_self
*= require_tree .
*/
The require_tree directive tells Sprockets to recursively include all CSS files in the specified directory into the output.
There are times that for some layout pages that we would like to exclude a couple of CSS files. Following two ways help us to accomplish this:
It may seem like a trivial decision at first glance, but using UUIDs can have an intricate effect on your applications design structure. If you are building an application and have an id:integer column that auto increments with the creation of every item you add to that table you could end up with some sever issues. As applications grow in size we end up having to seperate parts of the application into different servers: a cluster of database servers, background, jobs, cache server, an httpd server, and throw in a few servers for actual application and you’ve got a whole cluster of services to deal with.
Lets say you’ve got 3 servers running the actual application, each one chugging along running serveral instances of your web application. Now say it’s a basic CRUD application if you’ve got several instances writing to the database at once you will have a conflict. If you’ve got a table named books and a few rows are being added at once by seperate visitors, you’re auto incrimenting the rows
Although it may be obvious for many developers, there are still some that are not aware of great features that PostgreSQL allows to use with ActiveRecord. This tutorial is intended to reveal UUID type, which we can use in our Rails applications, especially as models’ attributes.
Special Postgre’s data types are available in our databases by enabling so called extensions. According to the documentation:
PostgreSQL is extensible because its operation is catalog-driven. The catalogs appear to the user as tables like any other. PostgreSQL stores much more information in its catalogs like data types, functions and access methods. These tables can be extended by the user. Traditional database systems can only be extended by changing source code or by loading modules written by the DBMS vendor. So not only we get a possibility to create our own extensions, but we get a bunch of useful features out of the box as well. Let’s see one of them in action right now.