Ruby on Rails 5.1.3RC1 released

Finally, new version of Ruby on Rails framework has been released
21 July 2017   699
Ruby on Rails

Framework written in the Ruby programming language

Great news for RoR coders. New 5.1.3 release candidate 1 version has been released.

Changelogs

List of changes for every gem:

  • Active Record:
    • Relation#joins is no longer affected by the target model's current_scope, with the exception of unscoped.
    • Previously, when building records using a has_many :through association, if the child records were deleted before the parent was saved, they would still be persisted. Now, if child records are deleted before the parent is saved on a has_many :through association, the child records will not be persisted.
  • Railities:
    • Make Rails' test runner work better with minitest plugins.
    • By demoting the Rails test runner to just another minitest plugin — and thereby not eager loading it — we can co-exist much better with other minitest plugins such as pride and minitest-focus.
    • Load environment file in dbconsole command.
    • Allow mounting the same engine several times in different locations.

As always, you can view whole list of changes at GitHub

If no regressions will be found, final release expected on Monday, 24th of July, 2017. Developers ask everyone who will face any issues, to open a GitHub issue and mention @kaspth in order to developers fix it as soon as possible.

SHA-256

Feel free to use this checksum in order to check version of your gem:

$ shasum -a 256 *-5.1.3.rc1.gem
3716fe810ac09651160af680e0622dba606eadc3532dc6100a09bc3dc46d8a79  actioncable-5.1.3.rc1.gem
9e734dcdb918f269bc027e31430648a58c205842b99c4990d19f33af41862027  actionmailer-5.1.3.rc1.gem
6f3739bea472a54a27b3982ea246028d4277580e2ff98c6343e07d95d54b29ad  actionpack-5.1.3.rc1.gem
482286af2d2146f6208e757fa29337dc73f9237c240bca753485992cf906bdb5  actionview-5.1.3.rc1.gem
2356ecbc1f1393a1577031894074d333fdc6d27e4ab9de796d2b97fff8676b8b  activejob-5.1.3.rc1.gem
f6ade74444578944fc3b8e376c4b050dda63bb7145abec4777dcb16867b42d30  activemodel-5.1.3.rc1.gem
72a886347747b61578a2aac1b34715042cb8f67fe43d8e53a2290220d08b8a3c  activerecord-5.1.3.rc1.gem
9220885a9d919430fa08cf72baf922000f7c36266d8f711498b7a6fb711eab2d  activesupport-5.1.3.rc1.gem
a06eded7f5e2bf1d6ecc69589062966bb701ccb8896d5aac5a6171ff38d037d4  rails-5.1.3.rc1.gem
727e65bc8c8fd359997bd1442c152f8628ddc318f68c9fba1ca603dda2db7766  railties-5.1.3.rc1.gem

 

DateTime, Timestamp, Time and Date in Rails

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

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.