Simply Rails 2 - belongs_to Clause - page 204
I'm following Simply Rails 2 and I am stuck at page 204
I modified the vote.rb file as follows:
then going over to the console I typed the following command:
class Vote < ActiveRecord::Base
and this was the reply from the console:
>> v= Vote.find( :first)
So far so good. So proceeding to the next step I typed the following command in the console:
=> #<Vote id: 1, story_id: 1, created_at: "2009-06-17 19:20:11", updated_at: "2009-06-17 19:20:11">
and this is the reply from the console:
NoMethodError: undefined method 'story' for #<Vote:0x3245524>
from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/attribute_methods.rb:205:in 'method_missing'
So using page 162 as a guide (because there was a NoMethodError in Stories#new), the book said the problem is:
Again, the book said that:
we haven't declared Story as a resource anywhere.
My routes.rb looks like this:
resources in Rails are declared in the file responsible for the Routing Configuration, config/routes.rb
So, I tried to add the following line to the routes.db file:
ActionController::Routing::Routes.draw do |map|
map.resources : votes
And this didn't solve the problem.
So, what exactly is the solution to this problem?
I tried searching for a solution on Google, also on Google blog search. Is there a site that anyone would recommend for information on dealing with Ruby errors?