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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With