ga-wdi-exercises / project3

[Project, Mongo, Mongoose, Node, Express, React, API] Prompt for 3rd WDI Project using React, Node, Mongo, Express and Mongoose
3 stars 4 forks source link

defining multiple state params from different factories #432

Closed justwes2 closed 7 years ago

justwes2 commented 7 years ago

We have a page where I want to add an instances of attendances, our join table. The function is called on an event page, and the user selects from a dropdown of students. I'm trying to figure out how to define the student ID by the dropdown selection and the event ID by the event page. What I have so far is:

this.addAttendance = function() {
        let attendance = {
          student_id: this.student.id,
          event_id: this.event.id
        }
      }

but that's erroring out at this.student= StudentFactory.query({id: $stateParams.id}); saying that query is expecting an array but getting an object. I'm not sure how to identify the student based on the selection in the dropdown menu.

superbuggy commented 7 years ago

Actually, only if you have include :event on your back end in the create method of your attendance controller does the second change make sense.

superbuggy commented 7 years ago

console.log(attendance) in the callback. we need more information here

superbuggy commented 7 years ago
          $state.go("eventShow", {id: event.id})
          // change to
          $state.go("eventShow", {id: attendance.event_id})
justwes2 commented 7 years ago

Ran the console log, nothing popped, so the addAttendance function isn't even touched.

superbuggy commented 7 years ago

How come the function isn't attached?

superbuggy commented 7 years ago

Can we close this issue and open up a new dedicated issue "Creating a new Attendance in ShowEventController"?

justwes2 commented 7 years ago

Sure.