Ruby on Rails 5.1.3 RC3 available now

Third released candidate for Ruby on Rails 5.1.3 released
01 August 2017   816
Ruby on Rails

Framework written in the Ruby programming language

Good news for RoR developers. New 5.1.3 release candidate 3rd version has been released.

Changelogs

List of changes for every gem:

  • Active Support
    • Fix modulo operations involving durations
      Rails 5.1 introduce an ActiveSupport::Duration::Scalar class as a wrapper around a numeric value as a way of ensuring a duration was the outcome of an expression. However the implementation was missing support for modulo operations. This support has now been added and should result in a duration being returned from expressions involving modulo operations.
      Prior to Rails 5.1:
      5.minutes % 2.minutes
      => 60

      Now:

      5.minutes % 2.minutes
      => 1 minute
    • Fix division where a duration is the denominator
      PR #29163 introduced a change in behavior when a duration was the denominator in a calculation - this was incorrect as dividing by a duration should always return a Numeric. The behavior of previous versions of Rails has been restored.

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

If no regressions will be found, final release expected on Thursday, August 3, 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.rc3.gem
f1b9758a78543bb27f65946a65a94e803140787b781f24983c696d89315685ea  actioncable-5.1.3.rc3.gem
8c57af610a7bac0cd91c0b09a0df2f66575ddb20204342b98d28bd6d051578b0  actionmailer-5.1.3.rc3.gem
9e69dcef628dbe12b5937a368e55ac79b71b38261d4187465200352d5278572d  actionpack-5.1.3.rc3.gem
d93ac77d4d6d2fa468a7407fda4088c9ca975aa00e78c18dd2b71e398af3b3dd  actionview-5.1.3.rc3.gem
2d0410f1a279b27e4bacddca4a8bc1f88c0e8c18429751370be8d41fb630cba9  activejob-5.1.3.rc3.gem
987567e336267497cb9222e4e689f58bfd06e9829071ae32d65b9a291fb0e8b3  activemodel-5.1.3.rc3.gem
159c9d330cec1ac9a92c9e0c68f0f088b4273f0ba163c3159f4a7369d9948229  activerecord-5.1.3.rc3.gem
6d4320c2e93e9f6239438cf7886b1111956b5d72cb5a7026402fa29021ae571f  activesupport-5.1.3.rc3.gem
f3551c5eec9649bc225552e0ed8ecee6dac9f4f97ca13e78bf018e36385852e8  rails-5.1.3.rc3.gem
59669b8098787c077b76642804a1543cdca8fabafabad7bbce74622508f79a3d  railties-5.1.3.rc3.gem

 

DateTime, Timestamp, Time and Date in Rails

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

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.