小编san*_*rom的帖子

Rails 3.1中SASS @import的问题

我在rails 3.1中使用SASS导入时遇到了一些麻烦.我已经尝试了分支'3-1-stable'和标签'v3.1.0.rc4'.

我的错误

Undefined variable: "$var1".
  (in app/assets/stylesheets/application.css.scss)
Run Code Online (Sandbox Code Playgroud)

应用程序/资产/样式表/ application.css.scss

@import "imp"; // defines $var1

body {
  border-right:5px solid $var1;
}
Run Code Online (Sandbox Code Playgroud)

应用程序/资产/样式表/ _imp.scss

$var1: "blue";
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails sass

4
推荐指数
1
解决办法
2059
查看次数

Backbone和bindAll:"func未定义"

我在使用bindAll时遇到了问题.我得到的错误是func is undefined.对我做错了什么的想法?

我试过了两个

  • bindAll (因上述错误而失败)和
  • 个人bind(不工作)
window.test = Backbone.View.extend({

  collection: null

  initialize: ->
    console.log('initialize()')
    console.log(this)
    # _.bindAll(this, ["render", "foo"])
    _.bind(this.render, this) # these don't throw errors, but binding won't work
    _.bind(this.foo, this) 
    @collection = new Backbone.Collection()
    @collection.bind "add",     @render
    @collection.bind "add",     @foo
    @render()

  foo: ->
    # won't be bound to the view when called from the collection
    console.log("foo()")
    console.log(this)
    console.log(this.collection) # undefined (since this is the collection, not the view)

  render: ->
    console.log("render()")
    console.log(this)
    return …
Run Code Online (Sandbox Code Playgroud)

javascript binding coffeescript backbone.js underscore.js

4
推荐指数
2
解决办法
2969
查看次数

Ruby和编码转换

我正在将CSV文件导入Ruby(1.8.7).File.open('path/to/file.csv').read在控制台中返回:

Stefan,Engstr\232m
Run Code Online (Sandbox Code Playgroud)

UniversalDetector(chardet gem)将编码标识为iso-8859-2.

UniversalDetector::chardet("Stefan,Engstr\232m")
=> {"confidence"=>0.626936305574385, "encoding"=>"ISO-8859-2"} 
Run Code Online (Sandbox Code Playgroud)

尝试转换字符串会产生以下结果:

Iconv.conv("UTF-8", "ISO-8859-2", "Stefan,Engstr\232m")
 => "Stefan,Engstrm"
Run Code Online (Sandbox Code Playgroud)

而我希望:

 => "Stefan,Engström"
Run Code Online (Sandbox Code Playgroud)
  • 字符串真的可以用于其他编码吗?
  • 我之前没有见过\ 232语法,通常当字符串奇怪编码时,会出现一些奇怪的字符,例如 或一些中文.

如果我应该提供更多信息或详细说明某些事情,请告诉我.

ruby string encoding ruby-on-rails

3
推荐指数
1
解决办法
1755
查看次数

Opera 中的 JSON 解析抛出“非法数字格式(尾随小数点)”

什么样的 JSON 可能导致 Opera 12(在其他浏览器中不会发生)抛出以下错误:

SyntaxError: JSON.parse: Illegal number format (trailing decimal dot)

客户告诉我他们收到了这个错误,但由于他们的技术水平不是很高,所以我无法引导他们足够远来挖出字符串。我尝试自己重现该错误,但到目前为止还没有成功。因此,我不知道导致此问题的 JSON 字符串。

javascript opera json syntax-error

0
推荐指数
1
解决办法
595
查看次数