天道酬勤,学无止境

coffeescript

Rails 咖啡脚本:类型错误:对象不支持此属性或方法(Rails coffeescript : TypeError: Object doesn't support this property or method)

问题 我有以下导轨配置: Windows 7 Rails 4.1.1 Ruby 2.0.0p481 Gem: coffee-rails 4.0.1 Gem: coffee-script 2.3.0 Gem: coffee-script-source 1.9.1 我有一个运行良好的应用程序,但现在不行了。 我不记得改变任何东西( git diff没有透露任何东西)。 我得到的错误是: TypeError: Object doesn't support this property or method (in c:/Users/mbratc01/Documents/Rails/manpower/app/assets/javascripts/welcome.js.coffee) Extracted source (around line #9): 7 <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => false %> 8 <%= javascript_include_tag 'jquery-1.11.1', 'data-turbolinks-track' => false %> 9 <%= javascript_include_tag 'application', 'data

2021-11-29 03:24:39    分类:技术分享    ruby-on-rails-4   coffeescript

How to enable harmony syntax support in coffeescript?

I used node.js(0.11.13) with --harmony flag and used function *() and yield keywords. I tried to simplify my development on node.js with help of coffeescript, so far it works great but I went into troubles with yield and declaring a generator - it complains about 'reserved keyword yield'. Any ideas?

2021-11-28 23:35:54    分类:问答    javascript   coffeescript   yield   ecmascript-harmony

how can I log every method call in node.js without adding debug lines everywhere?

I would like to log the user_id of the person making a request and the method name of every method called for a javascript class. For example: 35 - log_in 35 - list_of_other_users 78 - log_in 35 - send_message_to_user 35 - connect_to_redis 78 - list_of_other_users Since everything is async user 35 and 78 might be doing stuff at the same time. So I want to make sure each log line starts with their user_id so I can grep for it and only see one user's activity at a time. Is there a super clever way to do this without adding logger statements to every method?

2021-11-28 17:32:10    分类:问答    javascript   node.js   logging   coffeescript

MobileSafari won't send back Cookies set with CORS

I have a page loading up in MobileSafari which communicated with another server via CORS. In desktop browsers (tested Chrome and Safari), I am able to log in, get a session cookie, and have that session cookie be sent back for subsequent requests so that I may be authenticated with all API calls. However, when I login via Mobile Safari, the cookie does not get sent back on subsequent requests. I'm using Charles Proxy to spy on what's going on, and it tells me: POST https://myremoteserver.com/sessions.json passes up my login info It succeeds and response is received with a valid Set-Cookie

2021-11-28 17:20:02    分类:问答    javascript   ios   ajax   coffeescript   cors

Can I use CoffeeScript in the views executed on render.js?

What do I need to do so that I can use CoffeeScript in the Rails JS views? For example: def index format.js { render :layout => false } end What would I need to do in order for Rails to use index.js.coffee?

2021-11-28 17:10:39    分类:问答    ruby-on-rails   ruby   coffeescript

IDE or editor for Node.js+Express and CoffeeScript

Preferably an IDE. Integrated support for Subversion/Git is a big plus as we are a group of 6 people working. Vim/Emacs is not that popular with the other as it is very awkward and hard to get started and it requires alot of effort to learn which takes the focus away from our project. We're all used to/familiar with Eclipse, so an IDE that resembles Eclipse would be a big plus as well. Thanks :D

2021-11-28 15:51:47    分类:问答    javascript   node.js   ide   coffeescript   express

Good IDE for node.js + coffeescript + jasmine [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago. What good IDEs are there to develop with the combination of Jasmine, node.js and coffeescript. So far, we're considering WebStorm, but it is really hard to get started. We find very little documentation on node.js (and coffeescript) in

2021-11-28 14:34:39    分类:问答    javascript   node.js   coffeescript   jasmine   webstorm

Meteor,动态定义集合(Meteor, define collections dynamically)

问题 我们正在开发一个应用程序,需要能够动态创建新的 Mongo 集合。 目前我们有这样的代码: @Global = new Meteor.Collection('global') 我们在这个 mongo 集合中有一个看起来像这样的文档: { "title" : "room_list", "room_list" : ['chat1', 'chat2'], ... } 现在我想设置某种类型的循环或构造,基本上可以创建以下内容 @chat1 = new Meteor.Collection('chat1') @chat2 = new Meteor.Collection('chat2') 我们似乎需要这种类型的功能来动态创建新的数据集合。 我们正在研究某种类型的动态变量声明,或者是否有更好的方法来动态创建新的流星集合? 回答1 在大多数情况下,您可能不想创建多个集合,而是使用一个集合并根据客户的订阅将其视图发送给客户。 您可能想查看我构建的 https://github.com/mizzao/meteor-partitioner 包,该包是专门为此目的而设计的,其中包含一个示例,说明如何为多个聊天室执行此操作。 您还可以查看 https://github.com/mizzao/CrowdMapper 以获取已实现的示例。

2021-11-28 11:54:53    分类:技术分享    mongodb   coffeescript   meteor

Catching 302 error and then redirecting in backbone.js sync method override

What I want to do is catch a 302 error which means a user is not logged in, and then redirecting that user to the login page of the website. Here's my backbone.js sync override right now: parentSynchMethod = Backbone.sync Backbone.sync = (method, model, success, error) -> try parentSynchMethod.apply(Backbone, arguments) catch error window.location.replace("http://localhost:8080/login") The 302 error is definitely happening, I can see it in the network view when I inspect the page using google chrome. However, when I set a breakpoint, it never goes inside the catch, and the error argument is

2021-11-28 10:13:59    分类:问答    redirect   backbone.js   coffeescript   sync   http-status-code-302

ExecJS coffee script not showing line numbers for compile errors (Rails asset pipeline)

In one of my Rails apps, ExecJS is not showing line numbers for coffeescript compilation errors. My compile error message will look like this: ExecJS::RuntimeError in Referrals#new Showing ~/MyApp/app/views/layouts/application.html.erb where line #6 raised: SyntaxError: unexpected IDENTIFIER (in ~/MyApp/assets/javascripts/utils.js.coffee) Note that there's no line number for the coffee script source (line #6 is for the erb file). On another one of my apps, where I'm still getting the line numbers, a syntax error looks like this: ExecJS::ProgramError in Projects#show Showing ~/OtherApp/app

2021-11-28 06:49:36    分类:问答    ruby-on-rails   coffeescript   asset-pipeline   execjs