我正在研究这个访问模型层中的会话变量的应用程序.这似乎是错的,但我愿意被证明是错的.也许没有错,但是在应用程序的大多数地方,会话变量在控制器中处理并作为参数传入,但在其他地方,会话值只是被访问.我错了,这似乎是不好的做法?
编辑:我不喜欢模型中的会话的一个原因是它似乎使测试更复杂.保持它只是params传递给函数然后记录集传回.
谢谢
我正在尝试使用jQuery自动完成功能.我已经指定了一些数据但是当我在下拉列表中选择一个项目时,它总是将值推送到元区域元素中.我想要标签.这该怎么做?试图让它在#meta-area而不是值中显示标签.
HTML:
...
area:<input type='text' size='20' id='meta-area' />
<input type='hidden' id='meta_search_ids' value='' />
...
Run Code Online (Sandbox Code Playgroud)
JavaScript的:
$(document).ready(function(){
var data =[
{'label':'Core','value':1},
{'label':' Selectors','value':2},
{'label':'Events' ,'value':3}];
$("#meta-area").autocomplete({source:data,
select: function(e, ui) {
$("#meta_search_ids").val(ui.item.value);
// this part is not working
//$(this).val(ui.item.label);
$('#meta-area').text('this is what I want');
}
});
//alert("this loaded");
});
Run Code Online (Sandbox Code Playgroud) 我有以下代码,我想知道如何使最后一行工作.我addopted一组API,可目前使用_view追加,因为它的命名空间惯例,而宁愿使用类似arc.view.$函数名的.谢谢
var arc={};
arc.view={
say_hello: function(){
alert("I want to say hello");
}
}
function say_goodbye(){
alert("goodbye to you");
}
arc.view.say_hello(); // works
window['say_goodbye'](); // works
// possible to make this work?
window['arc.view.say_hello']();
Run Code Online (Sandbox Code Playgroud) 我已经采用了一个具有一些测试覆盖率的应用程序,但大多数测试都是混合质量的.该应用程序的大部分都是针对JSON API.我打算写请求规范但是进行身份验证然后发送带有身份验证数据的POST并不是一件容易的事.为了测试JSON api,控制器规格会更合适吗?
例如,
match 'api/login-mobile' => 'api#login_mobile', :as => :login_mobile, :defaults => {:format => 'json' }
Run Code Online (Sandbox Code Playgroud)
这似乎是微不足道的,但需要与capybara的集成规范.此外,capybara不会本地发送会话数据并且需要
page.driver.post .....
Run Code Online (Sandbox Code Playgroud)
我获得了用于测试UI交互的集成测试,但它似乎是测试JSON api的一个非常糟糕的模型.我错过了什么吗?或者是否有进行集成/ requeset测试的教程?我现在正在寻找话语,几乎所有的测试都是控制器....如果整合/请求规格是蜜蜂的膝盖,为什么他们会做出这个决定?
thx提前
我在话语中查看了一些代码并偶然发现了这一点,并想知道为什么klass = self.据我所知,他们比我更好的红宝石开发者,必须有充分的理由.
为什么他们不会调用self.remove_from_cache!(message ["key"],false)?块是否创建了一个新的范围,其中self指的是MessageBus的类?是否有其他示例需要在Ruby中创建这种类型的构造,或者这是主要的?如果MessageBus.subscribe是MessageBus的一个实例(比如说m_bus.subscribe),那么自己会在块中引用m_bus吗?Ensure_class_listener是类方法的事实是否与此有关?对不起,所有的问题,但只是想确定.
谢谢
https://github.com/discourse/discourse/blob/master/app/models/site_customization.rb#L118
def self.ensure_cache_listener
unless @subscribed
klass = self
MessageBus.subscribe("/site_customization") do |msg|
message = msg.data
# what would self her refer to
# what would self her refer to
# would self.remove_from_cache!(message["key"], false)
klass.remove_from_cache!(message["key"], false)
end
@subscribed = true
end
end
Run Code Online (Sandbox Code Playgroud)
MessageBus.subscribe的实现似乎在这里:https: //github.com/SamSaffron/message_bus/blob/master/lib/message_bus.rb#L217
我不是前端开发人员,但我正在尝试在 Rails 5.1 应用程序中整理我的 javascript/Vue.js 文件。我对节点生态系统不太熟悉。我收到以下错误,想知道从哪里开始解决这个问题:
Tue Apr 17$ eslint javascript/ --ext .vue
Cannot find module 'eslint-plugin-vue'
Referenced from: /Users/jt/repos/embers2/.eslintrc.js
Error: Cannot find module 'eslint-plugin-vue'
Referenced from: /Users/jt/repos/embers2/.eslintrc.js
at ModuleResolver.resolve (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/util/module-resolver.js:74:19)
at resolve (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/config/config-file.js:466:29)
at load (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/config/config-file.js:542:26)
at configExtends.reduceRight (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/config/config-file.js:421:36)
at Array.reduceRight (<anonymous>)
at applyExtends (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/config/config-file.js:403:28)
at loadFromDisk (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/config/config-file.js:514:22)
at Object.load (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/config/config-file.js:550:20)
at Config.getLocalConfigHierarchy (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/config.js:228:44)
at Config.getConfigHierarchy (/usr/local/lib/node_modules/eslint-config-airbnb-standard/node_modules/eslint/lib/config.js:180:43)
Tue Apr 17$
Run Code Online (Sandbox Code Playgroud)
我的 .eslint.js 文件是:
module.exports = {
extends: [
// add more generic rulesets here, such as:
// 'eslint:recommended',
'plugin:vue/essential', …Run Code Online (Sandbox Code Playgroud) 在Xcode 4中,当复制和粘贴文件时,我遇到了导致空白区域(它被修剪)的问题.在十六进制转储中,我0x20在源代码中看到s,但在副本中没有; 这意味着文本正在粘贴时更改.
在preferences > text editing > indentation,我有prefer indent using: spaces和tab key: indents in leading white space设定.
在尾随空格上不会发生这种情况.我该如何解决这个问题?
比方说,我有以下Javascript,
var User=Backbone.Model.extend({
});
var jt=new User({name:"jonathan"});
Run Code Online (Sandbox Code Playgroud)
我如何在Chrome控制台中访问jt?
>jt // doesn't work
>Backbone.... ?
Run Code Online (Sandbox Code Playgroud)
谢谢
在我的produ.rb中,我有
config.force_ssl = true
Run Code Online (Sandbox Code Playgroud)
并且想提供例外.看起来这应该工作(找不到如何回到3.2.19):
class ApiItemsController < ApplicationController
force_ssl except: :get_item_test
Run Code Online (Sandbox Code Playgroud)
但事实并非如此.我已经看过Rails 3.2 force_ssl,除了登陆页面,但真的不想为这样一个微不足道的东西添加宝石.我如何让它工作?

这是这个问题的后续问题:可能让CocoaPods有一个包含主应用程序的搜索路径
我想添加一个添加User Header Search Path到我的.podspec,以便在编译时添加它,但我不知道如何做到这一点,所以它的效果是这样的:
