首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Geddy -创建新项目

Geddy -创建新项目
EN

Stack Overflow用户
提问于 2013-03-05 16:28:34
回答 1查看 285关注 0票数 1

我是node.js和geddy的绝对初学者。我遵循了一些教程,现在我尝试为我的目的写一些类似的东西。

但是,当我尝试创建一个新项目时,我会得到以下消息:

代码语言:javascript
复制
/arithmetic_problem_types/function%20(id)%20%7B%20%20%20%20%20%20options.id%20=%20id;%20%20%20%20%20%20return%20helpersBase.urlFor.action(options);%20%20%20%20%7D not found.

我不知道这是从哪里来的。我仔细看过密码什么也没发现。

主计长:

代码语言:javascript
复制
var ArithmeticProblemTypes = function () {
  this.respondsWith =[ 'html', 'json', 'xml', 'js', 'txt'];

  this.index = function (req, resp, params) {
    var self = this;

    geddy.model.ArithmeticProblemType.all(function (err, arithmetic_problem_types) {
        self.respond({
            params: params, arithmetic_problem_types: arithmetic_problem_types
        });
    });
  };

  this.add = function (req, resp, params) {
    this.respond({
        params: params
    });
  };

  this.create = function (req, resp, params) {
    var self = this, arithmetic_problem_type = geddy.model.ArithmeticProblemType.create({
        name: '1', title: 'open', numberType: '1', numberRanges: '1', operators: '1', askedFor: '1', specialProblemCategory: '1', askedForNumDenomOrBoth: '1',
            reducedFractions:'1', mixedFractions: '1'
    });

    arithmetic_problem_type.save(function (err, data) {
        if (err) {
            params.errors = err;
            self.transfer('add');
        } else {
            self.redirect({
                controller: self.name
            });
        }
    });
  };
....................................................................
};

exports.ArithmeticProblemTypes = ArithmeticProblemTypes;

add.html.ejs

代码语言:javascript
复制
<div class="hero-unit">
  <%= partial('_form', {params: params}); %>
</div>

index.html.ejs

代码语言:javascript
复制
<div class="hero-unit">
  <h2>Arithmetic Problem Types List</h2>
  <%- linkTo('Create a new Aritmetic Problem Type', addArithmeticProblemTypePath, {class: 'btn pull-right'}) %>
</div>
<% if (arithmetic_problem_types && arithmetic_problem_types.length) { %>
  <% for (var i in arithmetic_problem_types) { %>
  <div class="row todo-item">
    <div class="span8">
      <h3><%- linkTo(arithmetic_problem_types[i].title, arithmeticProblemTypePath(arithmetic_problem_types[i].id)) %></h3>
    </div>
    <div class="span4"><h3><i class="icon-list-alt"></i><%= arithmetic_problem_types[i].status; %></h3></div>
  </div>
 <% } %>
<% } %>

我怎样才能摆脱这条信息,让它发挥作用呢?

编辑:--这是_form.html.ejs文件的开头:

代码语言:javascript
复制
<%
  var isUpdate = params.action == 'edit'
, formTitle = isUpdate ? 'Update this Arithmetic Problem Type' : 'Create a new Arithmetic Problem Type'
, action = isUpdate ? arithmeticProblemTypePath(params.id) + '?_method=PUT' : arithmeticProblemTypePath
, deleteAction = isUpdate ? arithmeticProblemTypePath(params.id) + '?_method=DELETE' : ''
, btnText = isUpdate ? 'Update' : 'Add'
, nameValue = isUpdate ? arithmeticProblemTypePath.name : ''
, errors = params.errors;
%>
<form id="arithmetic-problem-type-form" class="form-horizontal" action="<%= action %>" method="POST">
     ....
</form>

EDIT2:检查应该写入项目名称的页面并单击add按钮,我找到了以下内容

代码语言:javascript
复制
<div class="hero-unit">

  <form id="arithmetic-problem-type-form" class="form-horizontal" action="function (id) {
      options.id = id;
      return helpersBase.urlFor.action(options);
    }" method="POST">
  <fieldset>
    <legend>Create a new Arithmetic Problem Type</legend>
    <div class="control-group">
      <label for="title" class="control-label">Title</label>
      <div class="controls">
        <input class="span6" name="name" placeholder="enter name" type="text">

      </div>
    </div>

    <div class="form-actions">
      <input class="btn btn-primary" type="submit" value="Add">

    </div>
  </fieldset>
</form>
</div>

实际上,消息来自表单元素的action属性,但是我如何解决它呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-05 16:56:38

消息告诉您无法找到所请求的URL。又名404

/arithmetic_problem_types/function%20(id)%20%7B%20%20%20%20%20%20options.id%20=%20id;%20%20%20%20%20%20return%20helpersBase.urlFor.action(options);%20%20%20%20%7D

绝对不是个好看的url。所以我假设表单的action属性有问题。如果在验证表单时发生了这种情况。

如果单击该链接以“创建一个新的算术问题类型”时发生了这种情况,那么您可能应该在addArithmeticProblemTypePath后面加上括号

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15229067

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档