Steve Ross
Steve Ross

Reputation: 4144

Has Anyone Used Chronic or ChronicDuration in VoltRB?

I've put the chronic and chronic_duration gems in my Gemfile, and everything works fine in volt console. However, if I try anything on the client side, I get a name error. I tried requiring them in a client-side initializer, but that didn't help.

Any tips?

Upvotes: 0

Views: 53

Answers (2)

djboardman
djboardman

Reputation: 162

Just to add to Elia's answer, in Volt you can put use_gem in config/dependencies.rb (in the docs here)

This does work to load Chronic but it looks like Chronic won't run in Opal because it uses mutable strings - I get the following error:

Uncaught NotImplementedError: #<< not supported. Mutable String methods are not supported in Opal.

Upvotes: 1

Elia Schito
Elia Schito

Reputation: 979

You need to add the gem's paths to the paths Opal/sprockets searches looking for files.

For gems there's a nice helper:

 Opal.use_gem "chronic"

That should go in CRuby code (MRI) as early as possible during the initialization process.

Upvotes: 1

Related Questions