ActiveRecord 3+ auto-converts times to UTC by default. Hilarity ensues.
Remember how Rails 2 came with an awesome feature that broke all code using Time.now
or Time.parse
?
This behavior is now the default for Rails 3. Disable it by adding the following to your config/application.rb
:
config.active_record.default_timezone = :local
config.active_record.time_zone_aware_attributes = false
Related cards:
Split your parallel tests by execution time and keep execution logs up to date
Both knapsack
and parallel_tests
have the option to split groups by historic execution time. The required logs for this might be outdated since you manual...
ActiveRecord: validate_uniqueness_of is case sensitive by default
By default, Rails' validates_uniqueness_of
does not consider "username" and "USERNAME" to be a collision. If you use MySQL this will lead to issues, since string comparisons are case-insensitive in MySQL.
(If you use PostgreSQL, [read this in...
How to: Upgrade CarrierWave to 3.x
While upgrading CarrierWave from version 0.11.x to 3.x, we encountered some very nasty fails. Below are the basic changes you need to perform and some behavior you may eventually run into when upgrading your application. This aims to save you some...
Heads up: Capybara 3's text matchers no longer squish whitespace by default
Until Capybara 2, node finders that accept a text
option were able to find nodes based on rendered text, even if it spans over multiple elements in the HTML. I...
Ruby: Convert a time string to your local time zone
If you have a time given in a different time zone than your local one, parsing will convert it for you:
>> Time.parse('September 2nd, 3pm PST')
=> 2011-09-03 01:00:00 +0200
Note that in pure Ruby you need to require "tzinfo"
(Ruby 1.9)...
Configuring RubyGems to not install documentation by default
When installing gems, a lot of time is spent building locally installed documentation that you probably never use.
We recommend you disable documentation generation for gem install
by default.
Note that Bundler [won't install documentation](htt...
Puppet 3.x: Convert a float to an integer
There is no built in possibility to convert a float to an integer. You have to use an inline_template
inline_template('<%= @someFloat.to_i %>')
How Rails and MySQL are handling time zones
When working with times and dates in Rails applications, you need to deal with the following problem:
- In Rails,
Time
objects have a time zone. You can get the zone name by doingtime_object.zone
. - This zone is considered when doing time ca...
Steve Wozniak, Steve Jobs, and the long road to the iPad. - By Tim Wu - Slate Magazine
Now in 2010, the iPad takes the same ideas to their logical extreme. It is a beautiful and nearly perfect machine. It is also Jobs' final triumph, the final step in Apple's evolution away from Wozniak and toward a closed model.
Upgrade guide for moving a Rails app from Webpack 3 to Webpack 4
Webpacker is Rails' way of integrating Webpack, and version 4 has been released just a few days ago, allowing us to use Webpack 4.
I successfully upgraded an existing real-world Webpack 3 application. Below are notes on everything that I encounte...