Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uninitialized constant HomeController

ok, I've been following: http://railscasts.com/episodes/196-nested-model-form-part-1

Here are the steps I've had to accomplish so far:

rails new survey
<install the script stuff he includes>
rails g nifty:layout
rails g nifty:scaffold survey name:string
rake db:migrate

I updated routes.rb to point to home#index (rather then the welcome#index that it was) and deleted public/index.html

When I try to run rails server and go to my local host, I get the following error. uninitialized constant HomeController

I'm lost and have no clue what this means.

Can someone point me in the right direction?

EDIT:

OK, So I fixed that problem, I guess where I'm confused is where should my routes point to to ge to see the survey that I just created using the above commands. right now I'm pointing to my home#index, where should that point to?

Edit #2: Contents of Surveys_controller.rb

class SurveysController < ApplicationController
  def index
    @surveys = Survey.all
  end

  def show
    @survey = Survey.find(params[:id])
  end

  def new
    @survey = Survey.new
  end

  def create
    @survey = Survey.new(params[:survey])
    if @survey.save
      flash[:notice] = "Successfully created survey."
      redirect_to @survey
    else
      render :action => 'new'
    end
  end

 def edit
    @survey = Survey.find(params[:id])
  end

  def update
    @survey = Survey.find(params[:id])
    if @survey.update_attributes(params[:survey])
      flash[:notice] = "Successfully updated survey."
      redirect_to @survey
    else
      render :action => 'edit'
    end
  end

  def destroy
    @survey = Survey.find(params[:id])
    @survey.destroy
    flash[:notice] = "Successfully destroyed survey."
    redirect_to surveys_url
  end
end
like image 474
onaclov2000 Avatar asked Dec 16 '10 02:12

onaclov2000


1 Answers

With routes.rb pointing to home#index, it needs a HomeController in you app/controllers folder.

If you follow the tutorial exactly, you can point to just survey#index. Take a look at surveys.rb in app/controllers to see what pages are available. They were generated with the niffty_scaffold script.

like image 134
zsalzbank Avatar answered Sep 20 '22 04:09

zsalzbank