Problem with Ember Fixtures data loading

I've been working on integrating Ember fixtures data into a test app I'm developing with the ember-rails gem. The Chrome Ember inspector tool shows that the data model is loading, but the actual data isn't coming through.

Here's my current setup:

router.js

App.Router.map(function() {
  this.resource('projects'), { path: '/' };
});

store.js

App.ApplicationAdapter = DS.FixtureAdapter

models/project.js

App.Project = DS.Model.extend({
  name: DS.attr('string')
});

App.Project.FIXTURES = [
  { id: 1, 
    name: 'Test data 1'
  },
  { id: 2,
    name: 'Test data 2'
  }
];

routes/projectsRoute.js

App.ProjectRoute = Ember.Route.extend({
  model: function() {
    return this.store.find('project');                                            
  }
});

This project is built on top of rails using the ember-rails gem.

Any assistance would be greatly appreciated :)

Answer №1

If you're not adding FIXTURES as a key, it seems like the Model needs to be reopened:

App.Project.reopenClass({
  FIXTURES: [
    { id: 1, 
      name: 'Test data 1'
    },
    { id: 2,
      name: 'Test data 2'
    }
  ]
});

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

The variable you have attempted to access has not been assigned

Querying mongo through mongoose with customer.find() returns the following data: [{ _id: 5029a09e099fb5095fdb2d73, clientId: 22, company: 'X', email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="97cfd7 ...

What is the best way to consolidate promises produced by asynchronous functions in a Node.js stream callback?

In my Node.js TypeScript program, I am facing the challenge of parsing large CSV files line by line and asynchronously processing each line. Specifically, I require a function that will: Open a CSV file. Convert the next line into an object. (Ideally) Ga ...

Why does the MEAN Stack continue to route using the '#' symbol in the URL?

Currently navigating the realm of back end development. Started off by following a guide on express from thinkster. In need of some clarification. Initially, I grasped that front-end and back-end routing serve different purposes. Front-end routing relates ...

What are the steps to resolve the issue of "npm ERR! EEXIST: file already exists, rename" occurring with non-existent files?

Welcome to my first question post. (Please be kind if I make mistakes.) I am using node version 5.6.0. For an assignment, I downloaded a JS web app but am encountering an error that is preventing me from working on it: S:\PersonalCloud\jennyly ...

Finding out the specific row that was clicked in a Jquery Mobile listview

I've searched everywhere and can't find a solution. How can I retrieve the value of a row tapped in a listview? This could be anything from the name to the index within the object. Currently, I have a function handling the tap event. I need to pa ...

Designing a personalized node for a D3 force-directed graph while incorporating drag, zoom, and pan functionality

I'm currently integrating the D3 library into my React web application to generate a graph that showcases data. I've successfully set up all the desired features like drag, zoom, and pan. The final step is to customize the node element to display ...

Changing a DOM structure into pure HTML using JavaScript

Looking to convert some HTML into a PDF file using a service that requires form-data as the payload. Is there a way to extract HTML from the DOM and save it as a file for use in the payload? <p>some other HTML</p> <div id="content"> ...

The function window.open when using the target '_blank' will launch a fresh browser window

I'm attempting to open a link in a new browser tab (not a new window). When I place a link on the page like this: <a href="#" onclick="window.open('http://www.google.com', '_blank');"> Click Here</a> when a user clic ...

Having trouble with Javascript Array Push and Splice not functioning properly?

My goal is to replace the value "3" with "4" in the array. After this operation, only "1":"2" will remain in the array. const array = []; array.push({ "1": "2" }) array.push({ "3": "4" }) const index = array.indexOf(3); if (index > -1) { array.sp ...

Link a model to a User Model in an Express application using Mongoose

I am currently working on developing an application using the MEAN stack, and I'm still in the learning phase. One issue that I am facing is related to referencing my Surf Model to a User Model in express. My goal is to create a new Surf Object with a ...

Issue with using @ symbol in src alias in vite/vue project causing malfunction

Recently, I set up a Vue3/TS project using the Vite CLI The configuration in my vite.config.ts is as follows: import vue from '@vitejs/plugin-vue' import { defineConfig } from 'vite' import path from 'path' export default de ...

Optimize and compress your Angular 4 code

Currently, I am working with the Asp Core +Angular 4 template and using webpack in Visual Studio 2017. After publishing my app, when I check the content of ClientApp/dist/main-server.js, I notice that it is not minified or uglified. It looks something like ...

Redux persist isn't functioning properly as the rehydration process only happens one time

I am currently working with React version 15.4.2 and Redux, trying to persist my React/Redux state when the browser refreshes. Despite suggestions of using redux-persist, I encountered issues when following the basic instructions as the state resets to emp ...

Retrieve the error message from the service and pass it to the controller in AngularJS

Utilizing a factory to fetch rates via REST .factory('rateResource', ['$resource', function ($resource) { return $resource('/rates/:currency/:effectiveDate', { currency: '@currency', effectiveDat ...

`ACCESS DENIED: Unauthorized access attempt detected in Node.js``

When attempting to connect, MySQL is establishing a connection with an unfamiliar IP address. Refer to the code below: .env MYSQL_HOST=domain.example.com MYSQL_USER=**** MYSQL_PASSWORD=**** MYSQL_DB=**** MYSQL_PORT=3306 connection.js const mysql = requir ...

Tips for avoiding a button reverting to its original state upon page refresh

I have a button with the ID #first that, when clicked, is replaced by another button with the ID #second. However, if I refresh the page after clicking on the second button, it goes back to displaying the first button. Is there a way to make sure that th ...

Is there a way to merge two arrays with a specific condition?

I need to update the state in one array based on the values of another array. The goal is to include all statuses from the second array into the first without any duplicates. However, the provided sample code is not comprehensive. const arr1 = [{ agentId: ...

Unable to resolve eslint rule for formatting case statements within a switch statement

Looking at my sublime text window, I have a screenshot showing the eslint error that is being thrown for the switch / case statement. I'm aiming to indent 4 spaces, as shown in the code. https://i.sstatic.net/oQi63.png Here are 4 different attempts ...

transferring a value from php to javascript using a form's id

I'm facing an issue where I need to pass a dynamically generated ID from a form to JavaScript. <script type="text/javascript"> $(function() { $(".button-call").click(function() { var fld = "<?= $div_id;?>"; var test = $(fld).val ...

I have successfully implemented the Context API in my Next.js project and everything is functioning smoothly. However, I encountered an error while using TypeScript

Currently, I am working on a Next.js project that involves using the Context API. The data fetched from the Context API works perfectly fine, but I am encountering errors with TypeScript and I'm not sure how to resolve them. Error: Property openDialo ...