Search code examples
ruby-on-railstimezonesinatradashing

Sinatra - Dashing.io setting timezone


I've been trying to set the timezone of a dashing.io app (which runs under sinatra) with no success at all!

Doing: Time.zone ends up with NoMethodError - undefined method 'zone=' for Time:Class:

I've tried the solution at How to set timezone in ActiveSupport's TimeZone class :

require 'active_support/all'

But then i get the error: require': cannot load such file -- active_support/all (LoadError)


Solution

  • Active Support is not installed by default.

    There are two stages of using third-party library's.

    1. Installation
    2. Registration

    First things first, I assume that you follow the official guide on dashing.io.

    stage 1 - Installation

    With this in place you can add the gem activesupport which you need for this in to your Gemfile. Just adding a line like this:

    gem 'activesupport'

    After that you need to install it, you can do that with just running a second time bundle this fetch all gems and install it.

    stage 2 - Registration

    After you installed it, you can do what you tried with:

    require 'active_support/all'

    This tell that you load the active_support library.

    THE END

    After this two simple steps you can use Time.zone as expected.