balderdashy / balderdashy/sails

View Item REST is not working

Open
#4,540 7 comments 0 reactions 0 assignees View on GitHub
question resolved
Dominant language
JavaScript
Stars
22.8k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

**Sails version**: 1.0.2
**Node version**: 8.12
**NPM version**: 6.4.1
**DB adapter name**: mysql
**DB adapter version**: N/A
**Operating system**: windows



Hello, I am developping a crud application in sails for learning this framework before starting my project.
Actually i getting a issue in my source code which i coudn't detect the error. because there is no error message appeared for this.

**my source code: view**

> index.ejs
```
+ Ajouter


    <% users.forEach( function( users ){ %>
  1. <%= users.name %> (
    Supprimer
    |Modifier
    |Voir)

  2. <% }); %>

```

> view.ejs
```
+Ajouter|Lister|Modifier

View <%= users.name %>



  • Name:<%=users.name %>

  • Title:<%=title.name %>

  • Email:<%=users.email %>

```
> routes.js
```
'/user/index': {
controller: 'UsersController',
action: 'index'
},
'user/view': {
controller: 'UsersController',
action: 'view',
id: 'id'
}
```

> Controller actions

```
index: function (req, res) {
Users.find().exec(function (err, users) {
res.render('user/index', {'users': users});
return;
});
},

view: function (req, res) {
var id = req.param('id', null);
Users.findOne(id).done(function (err, users) {
res.render('user/view', {'users': users});
});
}
```

Contributor guide

Open the contributing guide

Research direction

Start with routes.js and the UsersController view action, then compare them with index.ejs and view.ejs. Reproduce the /user/view/:id request using the provided CRUD example and inspect the rendered result and server output. Done means the view-item route renders the selected user's details as intended.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mysql, node.js
Domain
backend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.