Ruby on Rails Monday, July 9, 2012

Here I Just started to learn Ruby on Rails! My issues is when reading
the data using my controller pages.

I initiate my controller using this command

rails g controller schoolTypes

I then initiate my model has the following command

rails g model schoolType

Once this is done i then modify has follow the following pages

create_school_type
class CreateSchoolTypes < ActiveRecord::Migration
def change
create_table :school_types do |t|
t.integer :schoolTypeID
t.string :name
t.description :text

t.timestamps
end
end
end
did a rake db:migrate

Change the following page

school_types_controller.rb
class SchoolTypesController < ApplicationController
def index
@schoolTypes = schooltype.all
end
def show
end
def new
end
def create
end
def update
end
def destroy
end
def edit
end
end

index.html.erb
<h1>School Types</h1>
<% @schoolTypes.each do |schoolType|%>
<%= schoolTypes.name %>
<% end %>
If I go to the following page http://localhost:3000/school_types I get
the following errors
undefined local variable or method `schooltype' for
#<SchoolTypesController:0xa9cd600>

Any reason why?

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en-US.

No comments:

Post a Comment