仅显示所需的参数 [英] Display only the desired parameters

查看:117
本文介绍了仅显示所需的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照本教程(没有脚手架)创建了一个应用.

I created an app following this tutorial (without scaffolding).

创建一个项目后,我可以单击它,它显示了一大堆参数.例如此处: http://s15.postimage.org/j6at9koiz/parameters.png .

After I create an item I can click on it and it shows me a big list of parameters. Like here: http://s15.postimage.org/j6at9koiz/parameters.png .

执行该操作的代码是

<% if (todos && todos.length) { %>
  <% for (var i in todos) { %>
  <div class="row todo-item">
    <div class="span8">
        <h3><%- linkTo(todos[i].title, todoPath(todos[i].id)) %></h3>
    </div>
    <div class="span4"><h3><i class="icon-list-alt"></i><%= todos[i].status; %></h3></div>
  </div>
  <% } %>
<% } %>

更具体地说,下面一行是显示带有标题的链接的链接,这些链接将我带到每个项目的参数列表:

To be more specific, the following line is the one which displays the links with the titles which take me to the list of the parameters for each item:

<%- linkTo(todos[i].title, todoPath(todos[i].id)) %>

我可以做些什么以仅显示某些参数,而不显示现在显示的整个列表吗?

Can I do something to display only some of the parameters and not the entire list which is displayed now?

谢谢!

推荐答案

您需要添加待办事项资源的视图文件.如果您使用的是脚手架,则geddy会默认创建它们.但是否则,您必须在app/views/todos中添加待办事项的视图文件.

You need to add view files for todo resource. If you're scaffolding, then geddy creates them by default. But otherwise, you have to add view files for todo in app/views/todos.

查看文件

  • _form.html.ejs
    • 修改/新表格
    • _form.html.ejs
      • edit/new form
      • 新资源视图
      • /todos/add
      • 修改视图
      • /todos/:id/edit
      • 索引视图
      • /todos
      • 显示个人资源
      • /todos/:id

      您可以手动编辑它们.要更改单个待办事项在/todos/:id路线上的显示方式,请编辑show.html.ejs

      You can edit them manually. For changing how a individual todo item should appear on /todos/:id route, edit show.html.ejs

      <div class="hero-unit">
        <%- linkTo('Edit this todo', editTodoPath(params.id), {class: 'btn pull-right'}); %>
        <h3>Params</h3>
        <ul>
          <li>todo.title</li>
          <li>todo.property1</li>
          <li>todo.property2</li>
        </ul>
      </div>
      

      这篇关于仅显示所需的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆