I entered this into the rails console-class Story < ActiveRecord::Base; end
and got compiler error message, this is on page 103...whats up?
| SitePoint Sponsor |
I entered this into the rails console-class Story < ActiveRecord::Base; end
and got compiler error message, this is on page 103...whats up?
can you post the details of the error message you're getting?
syntax error:compile error
(irb):1: class/module name must be constant
(irb):1: syntax error, unexpected kend expecting '\n' or ';'
Are you sure that the code you posted is exactly what you entered?
e.g.
Code Ruby:class Story < ActiveRecord::Base; end
The first error (class/module name must be CONSTANT) means that the name you give to a class when declaring it should be a Ruby constant. In ruby, constants must be named starting with a capital letter. So you'd most likely get that error if you tried to say "class story" instead of "class Story".
The second error (unexpected kEND) happens when the ruby interpreter comes to an "end" keyword that it wasn't expecting, here that could be because you omitted the semi-colon in the code you entered.
Bookmarks