Re: [getarailsjob] The action 'index' could not be found for PublisherController
- Allen Maxwell
- 2012-07-19 @ 15:31
when you create a controller using the rails generator, it creates the
associated actions and views etc that you specify in the command.
rails g controller MyControllers index edit create new
will create a controller and associated views for MyControllers (notice
the plural value) with the actions for index, create, and new…
if you manually create a controller file then you have to create the views too…
I'm assuming you have a MyController model also defined already… and I'm
also assuming that when you say "a second controller to handle a form"
you're talking about a new form and not a second controller to handle the
form you were already working with per "Hartl's instructions" …
Hope that helps.
On Jul 19, 2012, at 9:09 AM, Steve wrote:
> Hey guys,
> I'm needing to set up a second controller to handle a form. I set up the
first controller per Hartl's instructions. It runs great. So I built the
second controller exactly the same way, and it is throwing this error: The
action 'index' could not be found for PublisherController. I rtfm'd
(google), and found that people are saying that I need to c reate an index
page in the app/views/publisher folder.
> My question is, is this a separate file from new? If so, why didn't I
have to do that for the first controller. If it is a new file, do I put
all the information that I would normally put in new.html.erb into the
index.html.erb file? and then what happens to the new file?
> I hope that is clear.