Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

kevin hudson
Courses Plus Student 11,601 PointsError with ComicBooksController
SO the instructor didn't get an error at the end when he built the project but he should have because in the controller class he didn't update the Detail() return View
This was left:
public ActionResult Detail()
{
// return model instance comicbook
return View(comicBook);
}
What should go here?
2 Answers

Allan Clark
10,810 PointsThe video linked to this question does not seem to match up to your question as it is all about the repository class.
However to address your question, generally a Detail controller action should take in an int as a parameter. This int will be used to look up the entity that will be displayed. It should look something like the following:
public ActionResult Detail(int id)
{
var comicBook = ComicBookRepository.GetById(id);
return View(comicBook);
}
Please note this is essentially pseudo code and may not directly match up to how the project is structured, but it should give you an idea of what should go on in this controller action.

kevin hudson
Courses Plus Student 11,601 PointsWasn't exactly the answer but pretty close. It was addressed in the next video, I think. But what had happened was the instructor had kept all the comicbook array object data in the controller at that time even though he had moved it from the controller to a new class repo so it was still working correctly. I had cut and pasted the data out.
public ActionResult Detail(int? id)
{
if (id == null)
{
return HttpNotFound();
}
var comicBook = _comicBookRepository.GetComicBook(id.Value);
// return model instance comicbook
return View(comicBook);
}