GrailsInAction / graina2

Source code for the 2nd edition of Grails in Action
90 stars 93 forks source link

QOTD scaffold = true returns empty list if index() {} action method is present in controller #110

Open jkwuc89 opened 9 years ago

jkwuc89 commented 9 years ago

Section 1.5.1: This section indicates that all is required to enable scaffolding is to add the following: static scaffold = true This is not entirely true

If QuoteController still contains an index() action method, enabling scaffolding via static scaffold = true will result in an empty scaffold list page. To reproduce this, do the following:

  1. Add data to the DB (see section 1.4.2)
  2. Add static scaffold = true to the QuoteContoller.groovy
  3. Leave def index() {} action method inside this controller
  4. Start the app
  5. Browse to http://localhost:8080/qotd/quote/index

Notice that the scaffolding list page shows no quotes. Remove def index() {} from QuoteController and the list page will work as expected.

I suggest adding a note to section 1.5.1 about removing def index() {}

pledbrook commented 9 years ago

You raise a valid point. I think the assumption is that listing 1.1 contains the whole of QuoteController, which doesn't include the index action. But I think a clarification here would help.