require

Ruby: require vs require_relative - best practice to workaround running in both Ruby <1.9.2 and >=1.9.2

匿名 (未验证) 提交于 2019-12-03 01:54:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: What is the best practice if I want to require a relative file in Ruby and I want it to work in both 1.8.x and >=1.9.2? I see a few options: just do $LOAD_PATH and forget everything do $LOAD_PATH require './path/to/file' check if RUBY_VERSION require_relative as require , use require_relative everywhere where it's needed afterwards check if require_relative already exists, if it does, try to proceed as in previous case use weird constructions such as require File.join(File.dirname(__FILE__), 'path/to/file') - alas they don't seem to work in

How to configure CKEditor in Rails 3.1 (gem + Asset Pipeline)

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I've successfully configured the ckeditor gem from https://github.com/galetahub/ckeditor on my Rails 3.1 app. My problem now is that I can't figure out how to configure the CKEditor. The files that are used according to the Readme simply don't exists in a Rails 3.1 application with the asset pipeline enabled. 回答1: The answer was easy once i've figured out the thrown error message. /app/assets/javascript/ckeditor CKEDITOR . editorConfig = function ( config ) { config . toolbar_MyToolbar = [ { name : 'document' , items : [ 'NewPage'

PHP find require_once real path

匿名 (未验证) 提交于 2019-12-03 01:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i need to require_once this files main.class.php and functions.php and config.php to admin/test.php . how to php find require real path?! NOTE: main.class.php in class folder , functions.php in includes folder and config.php in root directory and test.php in admin folder . File Directory: root /admin/ ->test.php /class/ ->main.class.php /includes/ ->functions.php /templates config.php phpinfo.php 回答1: I would add your root folder to the include path and work from there. From admin/test.php set_include_path(implode(PATH_SEPARATOR, array(

Vue-Router: TypeError: this._router.init is not a function

匿名 (未验证) 提交于 2019-12-03 01:45:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have vue-router installed (within Laravel project), then try to use it: import VueRouter from 'vue-router' Vue.use(VueRouter) then I get this: [Vue warn]: Error in beforeCreate hook: "TypeError: this._router.init is not a function" Interestingly enough, everything was fine previously, but suddenly started getting this message. 回答1: Replace vue with vue-loader in your Webpack config https://github.com/vuejs/vue-loader/issues/409 UPDATE Okay, obviously you are not initializing the router in a proper way require('./bootstrap'); import Vue

requirejs - why loading module in define() works, but in require() doesn't

匿名 (未验证) 提交于 2019-12-03 01:44:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Code blow doesn't work, and the error msg is: Uncaught Error: Module name "text!templates/bookTemplate.html_unnormalized2" has not been loaded yet for context: _. Use require([]) define(['backbone', 'underscore', 'jquery'], function (Backbone, _, $) { var bt = require('text!templates/bookTemplate.html'); var BookView = Backbone.View.extend({ initialize: function () { this.render(); }, render: function () { var template = _.template(bt, { name: 'secret book' }); this.$el.html(template); } }); return BookView; }); then I move the "text

Getting error in logs ActiveSupport::MessageEncryptor::InvalidMessage when try to deploy Rails 5.2.0 App

匿名 (未验证) 提交于 2019-12-03 01:41:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to deploy a Rails 5.2.0 App on ec2 instance using mina deploy and When it tries to Migrate database it is aborted with following error logs. -----> Migrating database WARNING: Use strings for Figaro configuration. 2 was converted to "2". WARNING: Use strings for Figaro configuration. 5 was converted to "5". I, [2018-07-07T15:15:56.316810 #15933] INFO -- sentry: ** [Raven] Raven 2.7.4 ready to catch errors I, [2018-07-07T15:15:56.579121 #15933] INFO -- sentry: ** [Raven] Raven 2.7.4 ready to catch errors [Simple Form] Simple Form

Node.js require() vs RequireJS?

夙愿已清 提交于 2019-12-03 01:40:54
Hello with RequireJS I can set a base path like this: base : './app/' so when I am in ./app/foo/bar/ for example and I have a script where I use require('foo'); RequireJS then would search for ./app/foo.js and not in node_module folder or in ./app/foo/bar/foo.js this comes handy when you have a kind of structure where it would be much cleaner for you as a developer to see the dependencies instead of having ../../foo.js . I could have ./app/foo.js and ./app/foo/foo.js and ./app/foo/bar/foo.js it would be much more cleaner to have: require('foo'); require('foo/foo'); require('foo/bar/foo');

Node.js - require empty path

匿名 (未验证) 提交于 2019-12-03 01:39:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I came across this file on github, which does this: var migrate = require('../') What does that mean? When I tried the same, I get: Error: Cannot find module '../' 回答1: It requires the file index.js of the parent folder, which is this one: https://github.com/visionmedia/node-migrate/blob/master/index.js 回答2: Here is the document from the official node js website. I just put the full steps here, but in terms of your question, find ---- here is what you wanted to know ---- require(X) from module at path Y 1. If X is a core module, a. return

How can BlueZ be configured to require a connecting device to enter a matching pass key?

匿名 (未验证) 提交于 2019-12-03 01:39:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to setup Bluetooth on an embedded Linux device such that SSP mode is used, with my device generating and displaying a passcode on it's display, and the remote end (e.g. user's phone) being required to enter the matching passcode to be able to successfully pair. I'm written/registered an agent that sets it's mode to DisplayOnly; I expected that when a device connects the "RequestPasskey" callback would be called and that my agent would then be able to generate and return a new passcode, and that the remote end would be required to

Requirejs “text!” plugin alternative to webpack

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How to make this work in webpack? var templateHtml = require("text!templates/main.html"); console.log(templateHtml); // outputs string content of the "main.html" file I need to migrate from requirejs + require-text plugin to webpack with minimum code changes so I need that loader in webpack... Have any suggestions? 回答1: Should use 'text-loader': https://www.npmjs.com/package/text-loader My mistake was that I used both text! notation in require and loaders config with "text-loader". 回答2: As the other answer mentions, use https://www.npmjs.com