我用jQuery做这个:
@xmlOut = $('<rules />')
@xmlOut.attr('xsi:schemaLocation','test')
Run Code Online (Sandbox Code Playgroud)
我明白了:
<rules xsi:schemalocation='test'></rules>
Run Code Online (Sandbox Code Playgroud)
"L"不再是大写......
我想用Javascript/HTML 5做一个小游戏.对于这个游戏,我需要一个等距的地图,每个方格都是可点击的.
我该怎么做?你知道一些插件来帮助我做到这一点吗?
我找到这个解决方案http://www.cw-internetdienste.de/isomap/但结果不是很好......
谢谢
我正在尝试翻译我的申请.我把它放在config/application.rb中:
config.i18n.default_locale = :fr
Run Code Online (Sandbox Code Playgroud)
我创建了active_admin.fr.yml文件:
fr:
active_admin:
dashboard: "Tableau de Bord"
dashboard_welcome:
welcome: "Bienvenue dans Active Admin. Ceci est la page par défaut."
call_to_action: "Pour ajouter des sections au tableau de bord, consultez 'app/admin/dashboards.rb'"
....
Run Code Online (Sandbox Code Playgroud)
如果我将"fr:"更改为":en"它正在工作.
知道我做错了什么吗?(我重新启动了apache)
谢谢你的帮助.
编辑:
解决方案是使用:
I18n.default_locale = :fr
Run Code Online (Sandbox Code Playgroud)
并不是
config.i18n.default_locale = :fr
Run Code Online (Sandbox Code Playgroud) 使用我的rest API保存模型时遇到问题.我有一个卡模型,包含许多任务和一个客户关联:
class Card < ActiveRecord::Base
belongs_to :customer
has_many :card_tasks
has_many :tasks, :through => :card_tasks
accepts_nested_attributes_for :tasks
accepts_nested_attributes_for :card_tasks
accepts_nested_attributes_for :customer
end
class CardTask < ActiveRecord::Base
belongs_to :task
belongs_to :card
accepts_nested_attributes_for :task
accepts_nested_attributes_for :card
end
class Task < ActiveRecord::Base
has_many :cards, :through => :card_tasks
has_many :card_tasks
end
Run Code Online (Sandbox Code Playgroud)
当我像这样发送一个json:
{
"card" = > {
"miscellaneous" = > "Obervations diverses",
"heater" = > "0",
"water_quality" = > "",
"customer" = > {
"id" = > "2", "house_name" = > "house_name2", "city" = …Run Code Online (Sandbox Code Playgroud) 我想做这样的事情:
session[:continent][:filter] = params[:filter]
Run Code Online (Sandbox Code Playgroud)
但它不起作用,我得到了这个错误:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]=
Run Code Online (Sandbox Code Playgroud) 我试图在我的网站上聊天,看起来像谷歌谈话.我想管理断开连接事件.用户可以通过多种方式断开连接:
那么,我如何检测通道上的连接何时关闭?每个用户都有他自己的频道构建与他的ID.
谢谢你的帮助.
我翻译了我的活动管理菜单:
# encoding: utf-8
ActiveAdmin.register City do
menu :parent => "Données géographiques", :label => I18n.t(:cities)
end
Run Code Online (Sandbox Code Playgroud)
在我的active_admin.fr.yml中:
fr:
active_admin:
dashboard: "Tableau de Bord"
dashboard_welcome:
welcome: "Bienvenue dans Active Admin. Ceci est la page par défaut."
call_to_action: "Pour ajouter des sections au tableau de bord, consultez 'app/admin/dashboards.rb'"
cities: "Villes"
Run Code Online (Sandbox Code Playgroud)
在我的本地(debian 6),一切正常,但在我的前期制作(debian 6),它的写作:
translation missing: fr.cities
Run Code Online (Sandbox Code Playgroud)
我试图重启apache,清除缓存,重新加载I18n ......我失败了.
任何的想法?
我有一个对象MyObject:
class MyObject
def initialize(options = {})
@stat_to_load = options[:stat_to_load] || 'test'
end
def results
[]
end
end
Run Code Online (Sandbox Code Playgroud)
我想results只在那个方法存根stat_to_load = "times".我怎样才能做到这一点?我试过了:
MyObject.any_instance.stubs(:initialize).with({
:stat_to_load => "times"
}).stubs(:results).returns(["klala"])
Run Code Online (Sandbox Code Playgroud)
但它不起作用.任何的想法?
我正在使用带有rails的Devise,我想添加一个方法"getAllComments",所以我写这个:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :city, :newsletter_register, :birthday, :postal_code,
:address_complement, :address, :lastname, :firstname, :civility
has_many :hotels_comments
class << self # Class methods
def getAllComments
true
end
end
end
Run Code Online (Sandbox Code Playgroud)
在我的控制器中:
def dashboard
@user = current_user
@comments = @user.getAllComments();
end
Run Code Online (Sandbox Code Playgroud)
当我去我的网址时,我得到了
undefined method `getAllComments' for …Run Code Online (Sandbox Code Playgroud) 我有一个angularjs的问题.我创建了一个工厂事件,当我使用$ save方法时,d日期以UTC格式发送,而不是在浏览器时区中发送...
我创建了一个jsfiddle来说明它:
(单击"保存"按钮并打开控制台以查看请求参数)
我的代码:
window.App = angular.module('App', ["ngResource"]);
App.factory('Event', ['$resource', '$http', function($resource, $http) {
Event = $resource('/events/:id.json',
{ id:'@id' },
{ update: {method:'PUT' }, 'query': { method: 'GET', isArray: false }});
return Event;
}])
App.controller("EventNewCtrl", ['$scope', "$http", "Event", function($scope, $http, Event) {
$scope.resetEvent = function(){
$scope.event = new Event({ date: new Date() })
}
$scope.save = function() {
$scope.event.$save();
}
$scope.resetEvent()
}]);
Run Code Online (Sandbox Code Playgroud) javascript ×3
ruby ×3
activeadmin ×1
activerecord ×1
angularjs ×1
faye ×1
jquery ×1
mocha.js ×1
rest ×1
session ×1
stubs ×1
testing ×1
translation ×1
xml ×1