views:

39

answers:

3

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?

A: 

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/)

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

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/

jigfox
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
@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.
ryeguy
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
jigfox
A: 

file

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

must be present

Salil