小编win*_*yer的帖子

在Atom编辑器中使用RegEx组件进行搜索和替换

我想搜索并替换它

`https://example.com/`{.uri}
Run Code Online (Sandbox Code Playgroud)

[https://example.com/](https://example.com/)
Run Code Online (Sandbox Code Playgroud)

随着vim我会做s/(HTTP.*) {.uri}/[\1](\1)/g,但不与正常工作atom.io.我怎么解决这个问题?

regex atom-editor

120
推荐指数
2
解决办法
9万
查看次数

Rails检查yield:area是否在content_for中定义

我想在布局级别根据实际模板定义进行条件渲染content_for(:an__area),任何想法如何完成?

layout yield ruby-on-rails

93
推荐指数
2
解决办法
3万
查看次数

来自控制台的ActionCable.server.broadcast

我可以在控制器中使用以下代码,但不能在控制台中使用(两个开发环境).我正在使用Rails 5.0.0.beta2.

ActionCable.server.broadcast 'example_channel', message: '<p>Test</p>'
Run Code Online (Sandbox Code Playgroud)

控制台:

>> ActionCable.server.broadcast 'example_channel', message: '<p>Test</p>'
[ActionCable] Broadcasting to example_channel: {:message=>"<p>Test</p>"}
=> []
Run Code Online (Sandbox Code Playgroud)

我怎样才能在控制台中使用它?

ruby-on-rails ruby-on-rails-5 actioncable

32
推荐指数
1
解决办法
9017
查看次数

如何渲染hasMany关系数据?

如何在呈现URL /#/ persons/1时,获取以下示例代码,不仅可以呈现人员数据,还可以呈现该人员的电话号码.我试着通过电话号码循环,{{#each phoneNumber in phoneNumbers}}但我必须有一个基本的理解错误.

现在我只得到:

在此输入图像描述

app.js

App = Ember.Application.create({
  LOG_TRANSITIONS: true,
  rootElement: '#container'
});

// Router
App.Router.map(function() {
  this.resource('persons', function() {
    this.resource('person', { path: ':person_id' });
  });
  this.resource('phoneNumbers', function() {
    this.resource('phoneNumber', { path: ':phone_number_id' });
  });
});

App.PersonsRoute = Ember.Route.extend({
  model: function() {
    return App.Person.find();
  }
});

App.PhoneNumbersRoute = Ember.Route.extend({
  model: function() {
    return App.PhoneNumber.find();
  }
});

// Models
App.Store = DS.Store.extend({
  revision: 11,
  adapter: 'DS.FixtureAdapter'
});

App.Person = DS.Model.extend({
  firstName: DS.attr('string'),
  lastName: DS.attr('string'),
  phoneNumbers: DS.hasMany('App.PhoneNumber') …
Run Code Online (Sandbox Code Playgroud)

ember.js ember-data

11
推荐指数
1
解决办法
3993
查看次数

在使用http-mock的Ember CLI应用程序中配置CSP

我正在http://www.ember-cli.com/#ember-data上建议使用带有Ember CLI的http-mock .我理解CSP的基本概念,但我不了解它在Ember CLI应用程序中的配置.

如何配置我的应用程序以接受请求以localhost:4200/api/在开发期间避免这种情况:

Content Security Policy violation: {
    "csp-report": {
        "document-uri":"http://localhost:4200/products",
        "referrer":"",
        "violated-directive":"style-src 'self'",
        "effective-directive":"style-src",
        "original-policy":"default-src 'none'; script-src 'self' 'unsafe-eval' localhost:35729 0.0.0.0:35729; font-src 'self'; connect-src 'self' ws://localhost:35729 ws://0.0.0.0:35729 http://0.0.0.0:4200/csp-report; img-src 'self'; style-src 'self'; media-src 'self'; report-uri http://0.0.0.0:4200/csp-report;",
        "blocked-uri":"",
        "source-file":"chrome-extension://alelhddbbhepgpmgidjdcjakblofbmce",
        "line-number":1,"column-number":20481,"status-code":200
    }
}
Run Code Online (Sandbox Code Playgroud)

ember.js ember-cli http-mock

11
推荐指数
1
解决办法
3873
查看次数

在Ember.js应用程序中显示在线和离线(例如飞机)模式

Ember应用程序可以了解网络状态吗?如果是:如果应用程序可以访问互联网,我如何获取信息?我想根据网络可访问性切换GUI元素.

的index.html

<script type="text/x-handlebars">
  Status:
  {{#if isOffline}}
    Offline
  {{else}}
    Online
  {{/if}}
  <hr>

  {{outlet}}
</script>

<script type="text/x-handlebars" data-template-name="index">
  <h2>Hello World</h2>
</script>
Run Code Online (Sandbox Code Playgroud)

app.js

App = Ember.Application.create();
Run Code Online (Sandbox Code Playgroud)

javascript ember.js

10
推荐指数
2
解决办法
1894
查看次数

四处走动:请求的资源上没有"Access-Control-Allow-Origin"标头

我必须处理一个不受我控制的RESTful服务器.当我尝试从中获取ID 1记录时,这是我得到的错误:

XMLHttpRequest cannot load http://www.example.com/api/v1/companies/1.
No 'Access-Control-Allow-Origin' header is present on the requested 
resource. Origin 'http://localhost:4200' is therefore not allowed 
access.
Run Code Online (Sandbox Code Playgroud)

我可以curl在shell上:

$ curl -I http://www.company.com/api/v1/companies/1
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 11055
Content-Type: application/javascript
Last-Modified: Thu, 18 Jun 2015 07:30:26 GMT
Accept-Ranges: bytes
ETag: "5e772a598a9d01:0"
P3P: policyref="/w3c/p3p.xml",CP="CAO DSP LAW CURa ADMa DEVa CUSi OUR LEG UNI"
Date: Fri, 19 Jun 2015 13:06:46 GMT
$
Run Code Online (Sandbox Code Playgroud)

我使用以下contentSecurityPolicy:

contentSecurityPolicy: {
  'default-src': "'none'",
  'script-src': "'self'",
  'font-src': "'self'",
  'connect-src': "'self' http://www.example.com", …
Run Code Online (Sandbox Code Playgroud)

ember.js ember-data

9
推荐指数
1
解决办法
1万
查看次数

如何配置Ember CLI以使用uncss

我很难配置Ember CLI来使用uncss.设置:

> ember new foobar
> cd foobar
> bower install --save-dev bootstrap
> ember generate route index
Run Code Online (Sandbox Code Playgroud)

应用程序/模板/ index.hbs

<h1>Hello World!</h1>
Run Code Online (Sandbox Code Playgroud)

Brocfile.js

/* global require, module */

var EmberApp = require('ember-cli/lib/broccoli/ember-app');

var app = new EmberApp();

app.import('vendor/bootstrap/dist/css/bootstrap.css');

module.exports = app.toTree();
Run Code Online (Sandbox Code Playgroud)

我需要做什么才能使用https://github.com/sindresorhus/broccoli-uncsshttp://iamstef.net/ember-cli/的资产部分说它很容易,但它没有描述如何实际做到这一点.

ember.js ember-cli broccolijs

8
推荐指数
1
解决办法
561
查看次数

raails 5.1中的form_with搜索字段

在Rails 5.1中,所有表格都必须完成form_with.在http://edgeguides.rubyonrails.org/5_1_release_notes.html#unification-of-form-for-and-form-tag-into-form-with中,我只能找到与模型相关的表格示例.

在Rails 5.1中使用这个Rails 5.0表单的正确方法是什么form_with

<%= form_tag("/search", method: "get") do %>
  <%= label_tag(:q, "Search for:") %>
  <%= text_field_tag(:q) %>
  <%= submit_tag("Search") %>
<% end %>
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails ruby-on-rails-5 ruby-on-rails-5.1

8
推荐指数
2
解决办法
7698
查看次数

定制的脚手架模板

我已经更改了以下文件,以获得一个定制的脚手架生成器,在开发过程中节省了大量的工作.该deps目录是.gitignore这样,这不是分享与团队其他开发者这些变化的有效途径.定制这些默认模板的好方法是什么,以便开发团队中的每个人都可以使用它们?

$ tree deps/phoenix/priv/templates/phoenix.gen.html
deps/phoenix/priv/templates/phoenix.gen.html
??? controller.ex
??? controller_test.exs
??? edit.html.eex
??? form.html.eex
??? index.html.eex
??? new.html.eex
??? show.html.eex
??? view.ex
Run Code Online (Sandbox Code Playgroud)

phoenix-framework

6
推荐指数
1
解决办法
116
查看次数