I was trying to follow the step-by-step instructions in Grails In Action (http://www.manning.com/gsmith2/GiA2E_meap_ch01.pdf), and the scaffolding explained in section 1.5.1, Pg. 21-23 does not seem to be working for me.
I added the static scaffold = true
in the QuoteController.groovy
as suggested. Then did grails run-app, and when I head to localhost:8080/qotd/quote/list
I get a 404 error (instead of the Figure 1.11 in the pdf) as follows:
HTTP Status 404 - /qotd/quote/list
type Status report
message /qotd/quote/list
description The requested resource is not available.
Apache Tomcat/7.0.42
Here is the QuoteController.groovy
:
package qotd class QuoteController { static scaffold = true def index() { redirect(action: "home") } def home() { render "Real Programmers do not eat Quiche" } def random() { def allQuotes = Quote.list() def randomQuote def n = allQuotes.size() if (n > 0){ def randomIdx = new Random().nextInt(n) randomQuote = allQuotes[randomIdx] } else{ String str = "Real Programmers Don't Eat Quiche" + n randomQuote = new Quote(author: "Anonymous", content: str) } [quote: randomQuote] } }
However, going to localhost:8080/qotd/quote/create
works fine (matches with Figure 1.12 in the pdf), and I am able to create a new quote.
The versions I am using are:
App version: 0.1
Grails version: 2.3.1
Groovy version: 2.1.8
JVM version: 1.7.0_45
Is this a bug in Grails or I am missing something?
I am new to Groovy and Grails, and any help would be highly appreciated. Thank you!