Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMartin Torres
10,353 PointsMy ideas doesn't show
I checked my code and it's very similar to Craig's code, i don't know why it doesn't show the list of ideas
get("/ideas",(req,res) -> { Map<String,Object> model = new HashMap<>(); model.put("idea",dao.findAll()); return new ModelAndView(model,"ideas.hbs"); }, new HandlebarsTemplateEngine());
post("/ideas",(req,res) ->{ String title = req.queryParams("title"); CourseIdea courseIdea = new CourseIdea(title,req.cookie("username")); dao.add(courseIdea); res.redirect("/ideas"); return null; });
{{#partial "content"}} <h1>Current ideas</h1>
<ul>
{{#each ideas}}
<li>{{ title }}</li>
{{/each}}
</ul>
<form action="/ideas" method="post">
<input type="text" placeholder="What's your idea?" name="title">
<button>Suggest!</button>
</form>
{{/partial}} {{> base.hbs}}
1 Answer
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 PointsHere is Craigs code chunk
get("/ideas", (req, res) -> {
Map<String, Object> model = new HashMap<>();
//omiited code
model.put("ideas", dao.findAll());
// omitted code
return new ModelAndView(model, "ideas.hbs");
}, new HandlebarsTemplateEngine());
And here is yours
get("/ideas",(req,res) -> {
Map<String,Object> model = new HashMap<>();
model.put("idea",dao.findAll());
return new ModelAndView(model,"ideas.hbs");
}, new HandlebarsTemplateEngine());
Do you see the difference?
Martin Torres
10,353 PointsMartin Torres
10,353 PointsNow I see, thank you, I feel a little silly now that I saw my error. I appreciate your help :)