Uncaught ReferenceError: Foundation is not defined - ruby-on-rails

I am running into an several errors saying, "Uncaught ReferenceError: Foundation is not defined". They happen into the following:
- foundation.abide
- foundation.accordion
- foundation.clearing
- foundation.dropdown
- foundation.equalizer
- foundation.interchange
- foundation.joyride
In console, I typed Foundation, and got: Object {name: "Foundation", version: "5.5.1", media_queries: Object, stylesheet: CSSStyleSheet, global: Object…}global: Objectinherit: function (scope, methods) {init: function (scope, libraries, method, options, response) {init_lib: function (lib, args) {libs: Objectmedia_queries: Objectname: "Foundation"patch: function (lib) {rtl: falsescope: documentset_namespace: function () {stylesheet: CSSStyleSheetutils: Objectversion: "5.5.1"__proto__: Object.
I also verified that jQuery is working by using the console: $(document) resulting in [>#document].
I am running a Rails (4.2.1) stack on Ruby (2.0.0), and have been following the basic tutorial/walkthrough on zurb/foundation-rails.
rails g foundation:install
I have also tried RailsApps/rails_layout gem but am getting the same error.
rails generate layout:install foundation5 --force
The only thing I can think of is that I am defining Foundation after all the functions that needed it (abide, accordion, etc) but that shouldn't happen because the skeleton code is from the template generators. I'm not experienced in RoR or in the structure of Foundation to know if that's the case, so I was wondering where I can go about finding the error to this.
Or if this was just a client issue with my Mac.

This is caused by a bug in the 5.5.1.1 release of the foundation-rails gem. The plugins you listed above are loaded before the foundation code itself.
5.5.1.2 is on the way to fix this, but in the meantime you can resolve the issue by going back to the previous version:
gem 'foundation-rails', '= 5.5.1.0'

Related

CableReady (Rails) Basic case giving mystifying error message

cable_ready 4.5.0
rails 6.1.4.1
ruby 3.0.2p107
This is a simple example from the basic tutorial (https://www.youtube.com/watch?v=F5hA79vKE_E) I suspect the error I am getting is because either cable_ready or rails evolved a little and created a tiny incompatibility.
I get this error in the JS console:
It is triggered when in my controller I ask cable ready to:
cable_ready["timeline"].console_log(message: "***** cable ready post created")
Which leads to my timeline_channel to:
received(data) {
console.log("******** Received data:", data.operations)
if (data.cableReady) CableReady.perform(data.operations)
}
My interpretation is perform causes this line in cable_ready.js line 13:
operations.forEach(function (operation) {
if (!!operation.batch) batches[operation.batch] = batches[operation.batch] ? ++batches[operation.batch] : 1;
});
Is finding something in the received data that it doesn't like.
That's where my trail ends. Can someone see what I am doing wrong, or tell me what other code you'd like me to include?
Solution: downgrade the version of the cable_ready javascript library.
I previously (maybe a year ago) did this tutorial using CableReady 4.5, Ruby 2.6.5 and Rails 6.0.4 and it worked like a charm back then as well as today.
But today, I tried this tutorial again on a duplicate project--same versions of CR, Ruby, and Rails and now I get java console errors similar to yours.
TypeError: undefined is not a function (near '...operations.forEach...')
perform -- cable_ready.js:13
received -- progress_bar_channel.js:8
I looked at the output of yarn list and saw that cable_ready was version 5.0.0-pre8 on the bad project and it was 5.0.0-pre1 on the good project. The downgrade could be accomplished with yarn add cable_ready#^5.0.0-pre1 in the bad project folder and now both projects work.
FYI for other newbies like me trying to understand how CableReady works: This tutorial gives another example of CableReady, and was also fixed the same way.

TypeError: expect(...).toBeObservable is not a function - Jasmine marbles

I am trying to write a basic ngrx effects testing. However I keep getting the error as TypeError: expect(...).toBeObservable is not a function.
This is a new project setup with Angular 7. I had no issues with my previous projects which ran in angular 4.
Initially thought it could be something to do with packages so upgraded all packages to the most latest but no luck yet.
I event tried to test a very simple observable as expect(effects.test$).toBeObservable(5); but it gives the same error. As mentioned in the title I am using jasmine-marbles and the version is 0.4.1.
You need to init the test scheduler and add matchers in before each or toBeObservable will not be defined:
import { addMatchers, initTestScheduler } from 'jasmine-marbles';
beforeEach(() => {
...
initTestScheduler();
addMatchers();
});

Gmaps.build('Google') TypeError: undefined is not a function Gmaps4Rails

Using this gem: https://github.com/apneadiving/Google-Maps-for-Rails
I am trying to update to the newest gem version and experiencing a problem calling
Gmaps.build('Google') -> TypeError: undefined is not a function
but Gmaps is defined:
Gmaps -> Object {triggerOldOnload: function, loadMaps: function}
I have all followed the steps in the repo for the asset pipeline. Not sure what's causing this error.
You have legacy js somewhere because the code you have is from v1.x
You should just remove it.

Code from dart2js is throwing NoSuchMethodErrors for get$functions

My Polymer.dart web app, that works fine in Dartium, is giving the following error (it repeats seven times) when compiled with dart2js using pub build --mode=debug and loaded in Chrome.
Resource interpreted as Script but transferred with MIME type text/plain: "http://confab.dev/index.html_bootstrap.dart". confab.dev/:10
warning: file:///home/dan/projects/confabulous/webatara/web/index.html.0.dart library not found index.html_bootstrap.dart.js:17188
Uncaught Error: NoSuchMethodError: Cannot call "get$functions" on "#<JsLibraryMirror>" (Object #<JsLibraryMirror> has no method 'get$functions') index.html_bootstrap.dart.js:17188
Stack Trace:
TypeError: Object #<JsLibraryMirror> has no method 'get$functions'
at dart._loadLibrary (http://confab.dev/index.html_bootstrap.dart.js:20000:19)
at dart._loadLibraries (http://confab.dev/index.html_bootstrap.dart.js:19917:11)
at dart._initPolymerOptimized (http://confab.dev/index.html_bootstrap.dart.js:19908:7)
at dart.initPolymer (http://confab.dev/index.html_bootstrap.dart.js:19902:7)
at main (http://confab.dev/index.html_bootstrap.dart.js:4112:7)
at _IsolateContext.eval$1 (http://confab.dev/index.html_bootstrap.dart.js:1369:23)
at dart.startRootIsolate (http://confab.dev/index.html_bootstrap.dart.js:1145:21)
at http://confab.dev/index.html_bootstrap.dart.js:26514:7
at init.currentScript (http://confab.dev/index.html_bootstrap.dart.js:26494:5)
at http://confab.dev/index.html_bootstrap.dart.js:26508:3
index.html_bootstrap.dart.js:17188
Uncaught NoSuchMethodError: Cannot call "get$functions" on "#<JsLibraryMirror>" (Object #<JsLibraryMirror> has no method 'get$functions') index.html_bootstrap.dart.js:2369
Because source maps don't appear to work (they're turned on in Chrome, and I have .map files), I don't even know which part of my code is causing this.
I've tried with interop.js included both before dart.js, as the docs say, and after, as this issue says.
Looks like a bug in dart2js. Please file an issue, ideally with a reproducible test-case.
pub upgrade fixed it. It turns out that something had replaced the polymer 0.9.5 that I'd been using with 0.8.10+4. Quite odd. The solution to this is to set the polymer version as '>= 0.9.5' instead of 'any', which I will do eventually, but for now I'm interested to see if it happens again.

Compiled AngularDart fails with error in dynamic_injector

I have been trying to make AngularDart work but I always get exceptions for undefined objects.
#MirrorsUsed(
targets: const [
'angular.core',
'angular.core.dom',
'angular.core.parser',
'angular.routing',
'angular.core.zone',
'di.di',
'di.dynamic_injector',
NodeTreeSanitizer,
DynamicParser,
DynamicParserBackend,
Injector
],
metaTargets: const [
NgInjectableService,
NgComponent,
NgDirective,
NgController,
NgFilter,
NgAttr,
NgOneWay,
NgOneWayOneTime,
NgTwoWay,
NgCallback,
NgZone
],
override: '*'
)
import 'dart:mirrors';
And compiled javascript showing error:
Uncaught TypeError: Cannot call method 'get$parameters' of undefined dynamic_injector.dart:42
DynamicInjector.newInstanceOf$4 dynamic_injector.dart:42
When I'm removing MirrorsUsed2 there is no errors, but compiled file is large.
Adding these helped for me
'angular.filter',
'angular.perf',
'perf_api',
and instead of angular.core.parser
'angular.core.parser.dynamic_parser'
'angular.core.parser.lexer'
I also added all my own libraries.
See also https://code.google.com/p/dart/issues/detail?id=14686
Recently, I found Dart-AngularJS when compiled not to run, even the simplest example. I reinstalled my dart sdk to the latest stable version and the errors disappeared. Could you see if this works? Please see related issue on github project.

Resources