When deploying, Capistrano puts a
REVISION file into your application's release directory. It contains the hash of the commit which was deployed.
If you want to know the currently deployed release, simply SSH to a server and view that file.
$ cat /var/www/my-project/current/REVISION cf8734ece3938fc67262ad5e0d4336f820689307
When your application is deployed to multiple servers, you probably want to see a result for all of them.
Here is a Capistrano task that checks all servers with the
validates_uniqueness_of is not sufficient to ensure the uniqueness of a value. The reason for this is that in production, multiple worker processes can cause race conditions:
userstable and see that the name is available
I got this error after upgrading Ruby from 2.4.5 to 2.6.4 when I opened the Rails console -
rails server still worked.
Running via Spring preloader in process 14679
Loading development environment (Rails 220.127.116.11)
Traceback (most recent call last): …/lib/ruby/gems/2.6.0/gems/spring-2.1.0/lib/spring/application.rb:175:in 'fork': No such file to load – irb/encoding_aliases.rb (LoadError) …/lib/ruby/gems/2.6.0/gems/spring-2.1.0/lib/spring/application.rb:175:in 'fork': undefined method 'reject!' for nil:NilClass (NoMethodError) …/li…
If you're suffering from a huge
de.yml or similiar file, cry no more. Rails lets you freely organize your dictionary files in
My organization works like this:
This release makes it easier to migrate to a recent version of Unpoly when your app still depends on jQuery. Unpoly dropped its jQuery dependency with version 0.60.0, but retains optional jQuery support through functions like
up.$on(). All Unpoly functions that take a native element as an argument may also be called with a jQuery collection as an argument.
The following changes to the optional jQuery support were implemented:
This is not an issue in newer versions of HAML (starting with 5.0.0), as the
ugly-option was removed so that in development everything is rendered ugly, too.
When HTML is rendered from HAML in production or staging environment, whitespace is removed to reduce the download size of the resulting pages. Therefore it might happen that whitespace you see in development is missing in production or staging.
Here is an example of two inlined bootstrap buttons in a t…
We use bundler to maintain a projects gems. Unfortunately bundler v1 itself is incompatible with bundler v2.
You have two ways to update bundler on the server.
If you use our gem capistrano-opscomplete in your project, you can tell opscomplete to install the required bundler version:
Add the following line to
deploy.rb. If you use different deployment targets, add the follwoing line to the specific target configuration file. (e.g `product…
An alternative to this technique is using VCR. VCR allows you to record and replay real HTTP responses, saving you the effort to stub out request/response cycles in close details. If your tests do require close inspection of requests and responses, Webmock is still the way.
If you use webpacker in your Rails application, and you have completely disabled Sprockets, you might get the following error when trying to deploy:
Rails assets manifest file not found. This happens inside the
This task is build for Sprockets and does not work with webpacker. Simply skip it, by adding the following line to your
On application servers, gems are usually bundled into the project directory, at a location shared across deployments.
This is usually
shared/bundle inside your project's root directory, e.g.
If you can't find that, take a look at
current/.bundle/config and look for
When you are changing the version of RubyGems or Bundler on a system where gems are installed this way, you must wipe that bundle directory in addition to the user and system gems or gems that are already ins…
Capistrano automatically logs each (successful) deployment into a file on your application servers.
It is located at the root of your server's project folder, i.e. the parent of
current, like so:
/var/www/your-project$ ls current log releases repo revisions.log <--- here shared
Each line in that file contains the deployed branch, commit, release ID, and username (was read from the deploying user's machine):
$ tail -n3 revisions.log
Branch master (at da45511bea63002ac2ff002d1692e09d0dd7cb88) deployed as rel…
When an AJAX request raises an exception on the server, Rails will show a minimal error page with only basic information. Because all Unpoly updates work using AJAX requests, you won't get the more detailled better_errors page with the interactive REPL.
Below is an event listener that automatically repeats the request as a full-page load if your development error shows an error page. This means you get…
Basically, you now need to know if your project uses a "real" time zone or
:local, and if
config.active_record.time_zone_aware_attributes is set to
false or not.
With time zones configured, always use
ActiveRecord attributes will be time-zoned, and
.current values will be converted properly when written to the database.
Do not use
Time.now and friends. Timezone-less objects will not be converted properly when written to the database.
With no/local time zone use
Rails supports time zones, but there are several pitfalls. Most importantly because
Time.current are completely different things and code from gems might use one or the other.
Especially configuring an application that cares only about one time zone is a bit tricky.
The following was tested on Rails 5.1 but should apply to Rails 4.2 as well.
Your life will be easier if your application does not need to support time zones. Disable them like this:
config.time_zone = 'Berlin' # Your local time…
Webpacker is a wrapper around webpack that handles integration with Rails.
This is a short introduction.
If you haven't already, you need to install node.js and Yarn.
gem 'webpacker', '~> 4.x' # check if 4.x is still cu…
Travis changed their default distribution from Ubuntu 14.04 (trusty) to 16.04 (precise). This might break your test setup for new builds.
You can solve this issue by freezing your test distribution in the
.travis.yml to Ubuntu 14.04 until you have the time to solve all the issues you will have in 16.04:
Here are few indicators that you ran into this issue:
Your travis-ci builds might have started failing on the usual
The issue in this card can occur if the
node_modules directory is checked into your Git repository. We usually recommend to exclude
node_modules from version control.
In any case you should document which version of node to use in your project in a
I saw a strange behaviour after we introduced webpack in one of our projects and finally found out the reason: The person who committed the files used a node version that is older than mine.
Every time I wanted to run my rai…
When deploying with capistrano it's possible you get this "error" message:
*** [err :: example.com] There are no Phusion Passenger-served applications running whose paths begin with '/var/www/example.com'. *** [err :: example.com]
This is just because there were no running passenger process for this application on the server which could be restarted. It's not a real error. The application process will start if the first request for this app hits the appserver.
The output appears as
err because it's printed to