小编Dmi*_*eev的帖子

ActiveResource模型未初始化

我正在寻找使用ActiveResource,但现在面临一个我无法弄明白的问题(现在正在网上搜索解决方案的几天).

所以我有一个身份验证应用程序http://localhost:80和端口上的客户端:85

在我的auth应用程序中

我有一个User模型及其控制器,它遵循REST架构,并设置为响应xml调用.

这是我在我的auth应用程序中的内容:

车型/ User.rb

class User < ActiveRecord::Base
end
Run Code Online (Sandbox Code Playgroud)

*控制器/ users_controller.rb*

class UsersController < ApplicationController
respond_to :html, :xml, :js

def index
    @users = User.find :all
    respond_with @users
end

def show
    @user = User.find(params[:id])
    respond_with @user
end
.
.
.
end
Run Code Online (Sandbox Code Playgroud)

在客户端应用程序中

我有一个从活动资源扩展的类,如下所示:

车型/ user.rb

class User < ActiveResource::Base
    self.site = "http://localhost:80"
end
Run Code Online (Sandbox Code Playgroud)

以下是我尝试使用它的方法:*controllers/sessions_controller.rb*

class SessionController < ApplicationController

  def home
    @user = User.find(:all)
  end
end
Run Code Online (Sandbox Code Playgroud)

什么可能出错,对吧?

但后来我收到以下错误:

在2013-09-02 08:33:44开始获取"/"for 127.0.0.1 +1200
由SessionsController 处理#home 为HTML已完成500内部服务器错误
3ms

NameError(未初始化的常量ActiveResource): …

ruby-on-rails activeresource

9
推荐指数
3
解决办法
5193
查看次数

Webpack worker-loader无法编译Typescript worker

我按照worker-loader文档中的说明配置项目,并且能够使用正确的d.ts使TS代码intel正常工作。

但是,在webpack构建过程中会引发错误,我不明白为什么。

 ERROR in ./src/test.worker.ts
Module parse failed: Unexpected token (1:9)
You may need an appropriate loader to handle this file type.
| const ctx: Worker = self as any;
| ctx.addEventListener('message', event => {
|   console.log(event);
Run Code Online (Sandbox Code Playgroud)

我的工作人员文件内容test.worker.ts:

 ERROR in ./src/test.worker.ts
Module parse failed: Unexpected token (1:9)
You may need an appropriate loader to handle this file type.
| const ctx: Worker = self as any;
| ctx.addEventListener('message', event => {
|   console.log(event);
Run Code Online (Sandbox Code Playgroud)

申请表 index.ts

typescript webpack worker-loader

6
推荐指数
2
解决办法
2917
查看次数