Restore a DB dump with pg_restore is always a time-consuming process. However if you are using Postgres 8.4 or newer, you could speed it up easily by having multiple concurrent process do it for you.
In this short tutorial, I’ll show you how to update attributes for ActiveRecord model with:
- Validations are skipped.
- Callbacks are skipped.
updated_onare not updated.
Solutions for both Rails 3 and 4 are provided.
In my application, I bump to Exception when trying to delegate a method to an unfound ActiveRecord instance. This poses two issues for me:
- Hard to write test for you have to set up fixture/factory correctly
- Not a good user experience to see error on production
I tackle this with NullObject pattern to provide a graceful fallback.
Ruby gives us a nice human friendly
unless which is equivalent to negation of
if. Yet if we abuse using this method in a long complex statements, it could add more confusion for normal readers. In this article, I’ll give you one example to prove that you should not use
unless in a chain of conditions statement.
Puma is multi-threaded web server which is implemented in Ruby and has become a popular choice
for many production servers in the world. Given its short time of development, you’ll likely
to see issues. One of the issue that I and many people often bump into is processes management.
By default, puma offers
pumactl, yet this utitlity hasn’t lived up to expectation (this is a year
ago), thus people seeks different approaches with custom bash script by calling
upstart, monit, etc. However, today when I revisit
pumactl, this tool has been polished and
now does exactly what it promises. In this short article, I’ll go through with you how to use
pumactl to manage your puma processes.
In today tutorial, I’ll show you how to optimise a ActiveRecord import script by 300%. My solution is better than other solution as it doesn’t use any SQL hack, thus you can retain the integrity with the data by running it through ActiveRecord normally.
Running test suite is time consuming. There are various techniques to optimize the runtime performance of the CI by stub/mock, parallel_test, etc. In this short tutorial, I’ll show you how to optimize your TravisCI test suite by splitting your test suit into concurrent jobs, which drastically improve the build time.
In order to uninstall all gems, you have to loop through all entries in
gem list with bash scripting. This method is very inconveninent. Thanks to Rubygems 2.1.0, you now could do it with one command.
Majority of Ruby 2.0 syntaxes are backward-compatible with Ruby 1.9. Yet there is one tiny change in the way that Ruby 2.0 does lambda rocket that would break backward-compatability with Ruby 1.9. That is…a single space. Yes, you heard it correctly.
When upgrading my app from Rails 3.2.14 to Rails 4, I bumped into an error in which habtm association complains missing DB join table. To my surprise, Rails 4 has changed the default naming convention for join table.