Ember - Issue with Page Display

Currently tackling my first ember application, which consists of two pages: the Welcome page and a page displaying student details. To accomplish this, I have established two routes named index and studentdb. Unfortunately, I'm encountering an issue where the second page is not being displayed correctly. Utilizing Mirage in accordance with Ember's guidelines. Here's a snippet of the relevant code:

templates/index.hbs

<h1> Welcome </h1>

{{#link-to "studentdb"}}List{{/link-to}}

{{outlet}}

templates/studentdb.hbs

<h2> Welcome to Student Database </h2>
<h4> Following are the details </h4>

{{#each model as |student|}}
  <p>Name: {{student.Name}}</p>
  <p>College: {{student.College}}</p>
  <p>Department: {{student.Department}}</p>
{{/each}}

{{outlet}}

routes/studentdb.js

import Ember from 'ember';

export default Ember.Route.extend({

    model() {
        return this.store.findAll('student');
    }
});

models/student.js (model)

import DS from 'ember-data';

export default DS.Model.extend({
  Name: DS.attr(),
  College: DS.attr(),
  Department: DS.attr()
});

mirage/config.js

export default function() {

  this.get('/student', function() {
    return {
      data: [{
        type: 'student',
        id: 1,
        attributes: {
          Name: 'Archana',
          College: 'MNM Jain',
          Department: 'CSE'

        }
      }, {
        type: 'student',
        id: 2,
        attributes: {
          Name: 'Monica',
          College: 'Sathyabama',
          Department: 'IT'
        }
      }, {
        type: 'student',
        id: 3,
        attributes: {
          Name: 'Manoj',
          College: 'Kumarsaamy',
          Department: 'MECH'
        }
      }]
    }
  });
}

router.js

import Ember from 'ember';
import config from './config/environment';

const Router = Ember.Router.extend({
  location: config.locationType
});

Router.map(function() {
  this.route('studentdb');
});

export default Router;

If anyone can provide assistance, it would be greatly appreciated.

Encountering errors even after re-installing Ember based on the instructions outlined here: https://github.com/ember-cli/ember-cli/releases

npm WARN deprecated [email protected]: This package is no longer maintained. See its readme for upgrade details. npm ERR! registry error parsing json npm ERR! registry error parsing json npm ERR! registry error parsing json npm ERR! Windows_NT 6.1.7601 npm ERR! argv "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "[email protected]"npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! http://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request: npm ERR! C:\Users\learner\npm-debug.lo

Any assistance would be greatly appreciated.

Answer №1

It is essential to specify the route with this.get('/students', as it leverages the functionality of ember-inflector for url pluralization, following the guidelines set forth by jsonapi.org.

Answer №2

When I first started learning ember, I encountered a similar issue. I found a helpful discussion on github that made me realize my guides were newer than the version of ember-cli installed on my system:

https://github.com/samselikoff/ember-cli-mirage/issues/422

To resolve this, I decided to update ember to version 2.2.0-beta.3 by following these instructions:

https://github.com/ember-cli/ember-cli/releases

After updating ember and re-installing ember-cli-mirage, everything worked smoothly!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilize a date state variable in JSX Text based on a specific condition

My goal is to create a feature that allows users to pick a date using DateTimePickerModal. I want to display a clickable message that says "Select date" before any date is chosen, and then replace it with the selected date. While I am not certain if there ...

Guide to implementing onhashchange with dynamic elements

Hey there! I've encountered a problem with two select boxes on my webpage, each in different anchors (one on the page, the other in an iframe). What I'm trying to achieve is for the code to recognize which anchor it's in and then pass the se ...

The json_encode() function returned a JSON that is not valid

In my PHP file (although more complex, even with the simplest code it fails), I have: <?php $salida = array(1,2,3,4,5); echo json_encode($salida); ?> The response received is: [1,2,3,4,5] While this appears valid, it's actually not. When pas ...

The nested jade elements are failing to render

If I have a jade setup with 3 files as follows: 1. //layout.jade doctype html html body block content 2. //index.jade extends layout block content h1 Animals block cat block dog 3. //animals.jade extends index block cat p Meow block ...

The text box remains disabled even after clearing a correlated text box with Selenium WebDriver

My webpage has two text boxes: Name input box: <input type="text" onblur="matchUserName(true)" onkeyup="clearOther('txtUserName','txtUserID')" onkeydown="Search_OnKeyDown(event,this)" style="width: 250px; background-color: rgb(255, ...

Vue alerts and pop-ups will only show once

Utilizing vue ui to create a new project with Babel and Lint, I integrated dependencies vuetify, vuetify-loader, and vue-bootstrap. My goal was to have a simple 'open dialog' button that would reveal a dialog defined in a separate component file. ...

JavaScript: Retrieving the names of children within a <div> element

Within my structure setup, there is a tower div with inner elements like this: <div class="tower"> <div class="E0">abc</div> <div class="GU">123</di </div> The challenge I am facing is that I need to access the in ...

Sending a form without the need to reload the page

While it's known that Ajax is the preferred method to submit a form without refreshing the page, going through each field and constructing the Post string can be time-consuming. Is there an alternative approach that utilizes the browser's built-i ...

Ways to prevent the Layout component from rendering on the NextJS login page

Is there a way to prevent the rendering of the Layout component in NextJS when the route is /login, /register, etc? const MyApp = ({ Component, pageProps }) => { return ( <Layout> <Component {...pageProps} /> </Layout> ...

Loading vue.config.js Asynchronously for Pre-Rendering Meta Data

I am facing an issue with asynchronously loading data in my Vue.js application's config for use with Chris Fritz's PrerenderSPA webpack plugin. It seems that the routes are not being pre-rendered as expected. When I manually input the values, th ...

Proper technique for handling asynchronous results in a Vue component

Where is the ideal place to wait for a promise result in the Vue component lifecycle? Here's a runnable example: https://codesandbox.io/s/focused-surf-migyw. I generate a Promise in the created() hook and await the result in the async mounted() hook. ...

MUI: reveal multiple selection when hovering & prevent dropdown from moving around

Utilizing material ui, I am facing two issues with a multiple select component that I cannot seem to resolve: While selecting an item, the dropdown moves around (I have already attempted solutions like MenuProps={{ variant: "menu", getContentAnc ...

The error message "Next.js 14 does not recognize res.status as a function"

I'm a newcomer to Next.js and I've been wrestling with an issue all day. Here's my API for checking in MongoDB if a user exists: import {connect} from '../../../../lib/mongodb'; import User from '../../../models/userModel&ap ...

Vue automatically clears the INPUT field when disabling it

Have you ever noticed why Vue resets a text input field when it's set to disabled? This behavior is not observed with plain Javascript and also doesn't affect textarea fields. var app = new Vue({ el: '.container', data: { disab ...

What is causing the error message "TypeError: expressJwt is not a function" to appear? Is there a way to resolve it and fix the issue?

Authentication with JWT in Node.js: const expressJwt = require('express-jwt') function setupAuth() { const secret = process.env.SECRET_KEY return expressJwt({ secret, algorithms: ['HS256'] }) } module.expor ...

Suggestions for rectifying the calculation script to include the price, a phone number, 2 digits, and integrating a textfield for cost

I have developed a script that calculates prices, phone numbers, and extracts the last 2 digits from the phone number. In my website, the price is displayed through a select option. However, I am facing an issue where the cost does not automatically updat ...

401 Access Denied - Browser extension utilizing Angular JS

In my attempt to implement login functionality within a Chrome extension using Angular, I am consistently encountering a 401 UNAUTHORIZED error. Below is the code snippet I am using: angular.module('chrome-extension') .controller('LoginCont ...

Can you explain the functionality of isolate scope in angularjs?

I'm having trouble grasping the concept of scope : {}. Here's a snippet of code I've been working on. Why does it always display "strength" in the console instead of the actual array value? // Code goes here var app = angular.module("super ...

Pressing a sequence of buttons to meet a requirement using JavaScript

Currently, I have a set of four buttons that trigger an alert message when all of them are clicked. However, I am looking to modify this behavior so that the alert is displayed only when specific combinations of buttons are pressed, such as button1 and b ...

A simple guide on integrating personalized color palettes into Material-UI Theme

One enhancement I'd like to make in my theme is the inclusion of a custom color called warn import React from 'react' import { MuiThemeProvider } from '@material-ui/core/styles' import createMuiTheme from '@material-ui/core/s ...