当我使用ng-repeat(可能是一种无痛的方式)时,有没有人知道如何完全跳过 JSON排序?
例如,我的源JSON看起来像这样 -
{
"title": "Title",
"description": "Description",
"moreInfo": "Moreinformation"
}
Run Code Online (Sandbox Code Playgroud)
一旦我在ng-repeat中使用它,它就按字母顺序排序.像这样的东西 -
{
"description": "Description",
"moreInfo": "Moreinformation",
"title": "Title"
}
Run Code Online (Sandbox Code Playgroud)
我的ng-repeat看起来像这样 -
<div ng-repeat="(key,data) in items">
<span class="one"> {{key}} </span>
<span class="two"> {{data}} </span>
</div>
Run Code Online (Sandbox Code Playgroud)
我见过人们有一个单独的键数组,并使用它们来识别JSON对象,最终避免按字母顺序排序.
有一种优雅的方式来做到这一点?
我是Rails的新手,我不确定在添加资产时最佳做法是什么.
谁能告诉我在资产中使用Javascripts与使用相应的gem相比的优点和缺点?
我找到几乎所有我想要使用的JavaScript库的宝石.例如,IntroJS.我应该使用gem还是下载javascript并在我的资产中拥有库?
过去两天我一直收到这个错误.我已经尝试过每一个配置更改解决方案.该应用程序在我的本地环境中运行良好,但它似乎只在我部署到heroku时崩溃,所以我不确定我的代码是否有任何问题.任何人都可以建议下一步我能做什么?这是日志 -
2013-08-06T06:07:57.332143+00:00 app[web.1]: config.eager_load is set to nil. Please
update your config/environments/*.rb files accordingly:
2013-08-06T06:07:57.332143+00:00 app[web.1]:
2013-08-06T06:07:57.332143+00:00 app[web.1]: * development - set it to false
2013-08-06T06:07:57.332143+00:00 app[web.1]: * production - set it to true
2013-08-06T06:07:57.332143+00:00 app[web.1]: * test - set it to false (unless you use a tool that preloads your test environment)
2013-08-06T06:07:57.332143+00:00 app[web.1]:
2013-08-06T06:07:57.433472+00:00 app[web.1]: params or add `protected_attributes` to your Gemfile to use the old one.
2013-08-06T06:07:57.433472+00:00 app[web.1]: `config/application.rb` file and any `mass_assignment_sanitizer` options
2013-08-06T06:07:57.433472+00:00 app[web.1]: …Run Code Online (Sandbox Code Playgroud) 我在一个名为的数组中有一个经纬度数组lat_longs(看起来像这样 - [[39.749318, -104.9701129], [..], [..]]),我试图使用 Open Layers 3 在 OpenStreetMap 中绘制它们。这是我的代码 -
var icon_features = [];
$.each(lat_longs, function(index, item){
var point = new ol.geom.Point(item);
point.transform('EPSG:4326', 'EPSG:900913');
// I tried it the other way too, but doesn't seem to work
var iconFeature = new ol.Feature({
geometry: point,
name: item.name
});
icon_features.push(iconFeature);
});
var vectorSource = new ol.source.Vector({
features: icon_features
});
var vectorLayer = new ol.layer.Vector({
source: vectorSource
});
var view = new ol.View({
center: [0,0],
zoom: 2 …Run Code Online (Sandbox Code Playgroud) 我刚刚开始使用Rails4。我已经devise设置了自定义字段。注册后可以登录,但是无法从登录页面登录。用户注册进行得很好,并且数据库表中有username,password等等。
有人可以告诉我我所缺少的吗?我的用户模型非常基础。这是它的样子-
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
validates :username, :uniqueness => true, :presence => {:message => '- Username cannot be blank'}
validates :first_name, :presence => { :message => " - Firstname cannot be blank!"}
private
def user_params
params.require().permit(:first_name, :last_name, :username, :email, :password, :password_confirmation)
end
end
Run Code Online (Sandbox Code Playgroud)
我已经检查了视图,并传递了正确的参数。
我的应用程序控制器中有以下内容-
class ApplicationController < ActionController::Base
# …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过AJAX(使用PUT或PATCH请求)更新资源的属性,并且请求被多次触发.
我正在使用Angular JS和jQuery.
这是我的HTML模板的样子 -
<span id="test" ng-click="setValue('test')"></span>
Run Code Online (Sandbox Code Playgroud)
这是我的Angular JS代码的样子 -
$scope.setValue = function(value){
$.ajax({
method: 'PATCH' // or PUT,
url: 'resources/' + $scope.resourceId,
data: {
test: value
}
}).success(function(response){
console.log(response);
});
};
Run Code Online (Sandbox Code Playgroud)
以下是我的控制器更新方法的样子 -
def update
@resource.update(resource_params)
respond_with(@resource)
end
Run Code Online (Sandbox Code Playgroud)
AJAX请求被多次触发(接近15次).见下面的截图 -
通过简单地将PATCH(或PUT)请求更改为POST,调用仅被触发一次.见下面的截图 -
是否有任何理由为什么PUT请求被多次触发,而POST请求只被触发一次?
即使PUT请求正确更新了值.我想防止它被多次发射.有没有办法做到这一点?(不改变路线或控制器方法)
这是我第一次使用Paperclip和Amazon S3,我很确定我错过了一些明显的东西.如果有人可以指出它会很棒.
在S3存储桶中,我有2个文件夹,开发和生产,根据环境将图像上传到相应的文件夹.我尝试了这里提出的解决方案如下model.rb-
options = {}
if Rails.env.production?
options[:path] ||= 'production'
else
options[:path] ||= 'development'
end
has_attached_file :picture, options
Run Code Online (Sandbox Code Playgroud)
我不断收到一个名为development/production的文件上传到S3存储桶(如屏幕截图所示).

我甚至试过传递:path回形针的配置设置.同样的事情发生了 - 一个名为development/production的文件夹正在上传
我在这里错过了什么吗?我想做的就是,将我在开发环境中获得的图片上传到开发文件夹中,反之亦然.
嗨,我正在尝试使用控制器中的以下函数在 Laravel 中进行一个小型系统过滤,以按用户的角色或姓名过滤用户,这是我当前的代码:
配置文件控制器.php:
public function membrevis()
{
$filter = isset($_GET['filter']) ? $_GET['filter'] : null;
$users = DB::table('users')
->join('user_role', 'users.id', '=', 'user_role.user_id')
->join('roles', 'user_role.role_id', '=', 'roles.id')
->where('users.valid','=',0)
->select('users.*','roles.description');
if ($filter != null) {
$users->where('users.name','like','%'.$filter.'%')
->orWhere('roles.description',' like','%'.$filter.'%');
}
$users->get();
return view('membre2',['users'=> $users]);
}
Run Code Online (Sandbox Code Playgroud)
我的视图有一个输入表单,您可以在其中键入要过滤的成员的姓名或角色:
membre2.blade.php:
<form action="/profilecontroller/membrevis" method="get">
<input type="text" name="filter" >
<button type="submit">filter</button>
</form>
@foreach($users as $users)
<h4 class="media-heading">{{ $users->name }}</h4>
@endforeach
Run Code Online (Sandbox Code Playgroud)
我得到的错误是 Undefined property: Illuminate\Database\MySqlConnection::$name
我不知道为什么我会收到这个错误,我显然是用这行命令将 $users 传递给我的视图:
return view('membre2',['users'=> $users]);
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激!谢谢你
我是持续集成和Cruise Control的新手.但我看了几个例子,我尝试将项目设置为预先存在的Cruise Control设置,其中包含几个项目.
我确定,所有文件都正确指向我修改了正确的ccnet.config.
但是,我添加的项目没有显示在Web仪表板中.
这是我在ccnet.config中添加的项目块.(出于安全原因,删除了元素中的值,但我确信这些值都很好.)
<project>
<name></name>
<workingDirectory></workingDirectory>
<artifactDirectory></artifactDirectory>
<webURL></webURL>
<modificationDelaySeconds></modificationDelaySeconds>
<triggers>
<intervalTrigger seconds="1200" buildCondition="IfModificationExists" />
</triggers>
<sourcecontrol type="svn">
<executable></executable>
<workingDirectory></workingDirectory>
<autoGenSource>true</autoGenSource>
<trunkUrl></trunkUrl>
<username></username>
<password></password>
</sourcecontrol>
<tasks>
<nant>
<executable></executable>
<baseDirectory></baseDirectory>
<buildFile></buildFile>
<targetList>
<target></target>
</targetList>
<buildTimeoutSeconds>600</buildTimeoutSeconds>
</nant>
</tasks>
<publishers>
<xmllogger logDir="" />
<artifactcleanup cleanUpMethod="KeepLastBuilds" cleanUpValue="10" />
</publishers>
</project>
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?修改ccnet.config后是否还需要执行其他操作?这里的任何指导都会非常有帮助.
cruisecontrol.net continuous-integration cruisecontrol ccnet-config
我看到很多线程都在讨论使用getNodeById或getRootNode方法和appendChild方法向TreePanel添加动态节点.
出于某种原因,我无法做到.我不知道我做错了什么,或者这是否与Ext JS 3.4有关.
有人可以告诉我这是对的吗?
{
xtype: 'treepanel',
id: 'testTreePanel',
autoScroll: true,
width: 250,
collapsible: true,
title: 'Navigation',
containerScroll: true,
enableDD: true,
useArrows: true,
collapsible: true,
region: 'west',
root: {
allowDrag: false,
allowDrop: false,
iconCls: 'cover',
id: 'testRootNode',
text: 'Root Node'
},
loader: {
}
}
Run Code Online (Sandbox Code Playgroud)
这是我正在做的动态添加节点 -
var testNode = new Ext.tree.TreeNode({
id: 'node_1',
leaf: true,
text: 'Test Node Text 1',
allowDrag: false,
allowDrop: false
});
Ext.getCmp('testTreePanel').getRootNode().appendChild(testNode);
Run Code Online (Sandbox Code Playgroud)
我看到节点已添加到根目录下,如果我这样做 -
Ext.getCmp('testTreePanel').getRootNode().childNodes
Run Code Online (Sandbox Code Playgroud)
但我也注意到root了allowChildren: false,loaded: false, …