Rails 4.2.10.rc1 available now

New release candidate for Ruby on Rails 4.2.10 available now with some valuable fixes
21 September 2017   499

According to Rails developers release policy, Rails 4.2 is no longer supported except for severe security fixes, but the last release introduced some regressions that warranted a release.

If no new issues are found, the final release is expected on Wednesday, September 27, 2017. If you will find a regression, developers ask you to open an issue on GitHub and mention @eileencodes on it.

Changes

Let's check what's new for every gem. 

  • Active Record
    • Relation#joins is no longer affected by the target model's current_scope, with the exception of unscoped.
  • Action Pack
    • Fix regression in behavior of normalize_path.
      In Rails 5 there was a change to ensure the encoding of the original string in a path was maintained. This was incorrectly backported to Rails 4.2 which caused a regression.

The remaining gems (Action Mailer, Action View, Active Job, Active Model, Active Support, and Railties) had no changes. 

To see full changeslist, check GitHub.

SHA-256

Use this checksum in order to verify your version of a gem.

$ shasum -a 256 *-4.2.10.rc1.gem
91f279396cd0757784445294a0422c37113a6d49c856ed1b6ce60cd2d6cd4c57  actionmailer-4.2.10.rc1.gem
2f582b5c3b42dea2a877af76812168ad721b583f501c748c32699686d8996c6e  actionpack-4.2.10.rc1.gem
1f587908650b6e96a500de3ccbeb229e8ffe1b8a06bbadc930acad762dd70503  actionview-4.2.10.rc1.gem
b68b1e2475e6cb118a66c9b1daa172965b634b311e81e6ec686f819f0c71c1c4  activejob-4.2.10.rc1.gem
18507309ed0f00f5a6ffc09da1df5076f016f516ce8e7afe2b4138353ca7c915  activemodel-4.2.10.rc1.gem
53a094625fe76d353d95cfd5cf0d989e5f0f18572cded546e3942e2647fdac5e  activerecord-4.2.10.rc1.gem
e4bb02e67d57e9c52fbe0f90b367eb653f4906351b470ce60b34556bb5710b96  activesupport-4.2.10.rc1.gem
9e43e2cda17c4d68b65eff9ef4df6c62c87a0f5779a612fd3dc06e80f0182c7c  rails-4.2.10.rc1.gem
360a5c67a78c5fffaa27c6caa6ae4663d49ab675507ed61f95d2f51869b671b4  railties-4.2.10.rc1.gem

 

DateTime, Timestamp, Time and Date in Rails

Learn about key differenece between DateTime, Timestamp, Time and Date in Rails
31 October 2017   593

The difference between different date/time formats in ActiveRecord have little to do with Rails and everything to do with whatever database you're using.

Using MySQL as an example (if for no other reason because it's most popular), you have DATEDATETIMETIME and TIMESTAMP column data types; just as you have CHARVARCHARFLOATand INTEGER.

So, main differences: DATE only stores a date, TIME only stores a time of day, while DATETIME stores both.

The difference between DATETIME and TIMESTAMP is a bit more subtle: DATETIME is formatted as YYYY-MM-DD HH:MM:SS. Valid ranges go from the year 1000 to the year 9999 and everything in between. While TIMESTAMP looks similar when you fetch it from the database, it's really a just a front for a unix timestamp. Its valid range goes from 1970 to 2038. The difference here, aside from the various built-in functions within the database engine, is storage space. Because DATETIMEstores every digit in the year, month day, hour, minute and second, it uses up a total of 8 bytes. As TIMESTAMP only stores the number of seconds since 1970-01-01, it uses 4 bytes.

You can read more about the differences between time formats in MySQL here.

In the end, it comes down to what you need your date/time column to do. Do you need to store dates and times before 1970 or after 2038? Use DATETIME. Do you need to worry about database size and you're within that timerange? Use TIMESTAMP. Do you only need to store a date? Use DATE. Do you only need to store a time? Use TIME.

Having said all of this, Rails actually makes some of these decisions for you. Both :timestamp and :datetime will default to DATETIME, while :date and :time corresponds to DATE and TIME, respectively.