Sha256: 7b731957a91105697609df5206021b0b42181a761bac07252c16ebf345ae54f8

Contents?: true

Size: 1.1 KB

Versions: 22

Compression:

Stored size: 1.1 KB

Contents

# Copyright 2021 Google LLC
#
# Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.

require "io/console"
require_relative "../config/environment"
require_relative "models/singer"

class Application
  def self.run
    # Get all singers order by birthdate
    puts ""
    puts "Listing all singers order by birth date:"
    Singer.all.order(:birth_date).each do |singer|
      puts "#{"#{singer.first_name} #{singer.last_name}".ljust 30}#{singer.birth_date}"
    end

    # Update the birth date of a random singer using the current system time. Any time and timezone information will be
    # lost after saving the record as a DATE only contains the year, month and day-of-month information.
    singer = Singer.all.sample
    singer.update birth_date: Time.now
    singer.reload
    puts ""
    puts "Updated birth date to current system time:"
    puts "#{"#{singer.first_name} #{singer.last_name}".ljust 30}#{singer.birth_date}"

    puts ""
    puts "Press any key to end the application"
    STDIN.getch
  end
end

Application.run

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
activerecord-spanner-adapter-1.8.0 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.6.3 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.6.2 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.6.1 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.6.0 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.5.1 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.5.0 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.4.4 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.4.3 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.4.2 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.4.1 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.4.0 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.3.1 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.2.2 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.2.1 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.2.0 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.1.0 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.0.1 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-1.0.0 examples/snippets/date-data-type/application.rb
activerecord-spanner-adapter-0.7.0 examples/snippets/date-data-type/application.rb