0

NameError in GenresController#index

uninitialized constant GenresController RAILS_ROOT: C:/Users/Will/Desktop/INSTAN~1/rails_apps/talewiki

I've created a table called Genres and when I try to connect to it via local host I get the above error.

Any ideas?

4
  • 1
    That means you don't have a Controller for you Genres Model Commented May 26, 2010 at 13:22
  • its there but its called index.html.erb, if I rename it to index.html will it work? Commented May 26, 2010 at 13:37
  • index.html.erb is not a controller. it is a view file. The Right controller file would be app/controllers/GenresController.rb Commented May 26, 2010 at 13:38
  • Just checked I have actually got a genres_controller.rb file Commented May 26, 2010 at 13:47

3 Answers 3

1

With all the questions you're asking I believe you're an absolute beginner regarding ROR. Perhaps you should visit some tutorials to learn rails.

I don't know what your genre model describes, but I think it will have a name.

Basic steps for a basic genre model:

  1. Delete the table for your genres if created manually (with SQL code)

    DROP TABLE genres;
    
  2. generate a complete scaffolding for genres:

    $ ruby script/generate genre name:string
    $ rake db:migrate
    
  3. Now you have a complete controller for all CRUD actions for a simple genre model

If I were you I would read some tutorial about RoR, because you make the impression that you don't understand RoR or the MVC principle behind it. A good start would be: http://storecrowd.com/blog/top-50-ruby-on-rails-tutorials/

Sign up to request clarification or add additional context in comments.

3 Comments

Yeah I'm totally a beginner, I think I'm rubbing shoulders with people too experienced on here. I'm basically following a tutorial at the moment that obviously doesn't work, which is a shame. Anyway - thanks for the link, I'll get back to the drawing board and stop hounding you.
@wannabe: You should pick up the "agile development in rails" book. It's the bible for learning RoR, and there really isn't anything out there that's as complete as it is.
I can't agree more with ryeguy. That's almost always the way I go to learn something new. I buy a Book (if it's the right one it will almost always be better as any online tutorium) then if I go into specifics I use google and SO. @WANNABE you should not be afraid of hounding us ;-) SO is here to ask Questions
0

You need to generate a controller to handle the index action when your browse your application on localhost

ruby script/generate controller genres index

run that from your console within your application and it will generate the GenresController with the action index (it will be an empty action but you shouldn't see an error when browsing http://localhost:3000/genres/)

2 Comments

its there but its called index.html.erb
You're talking about the view, the controller is actually what serves the view. What exists in your app/controllers folder?
0

file

C:/Users/Will/Desktop/INSTAN~1/rails_apps/talewiki/app/controllers/genres_controller.rb

must be present

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.