SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Oct 11, 2009, 14:45 #1
- Join Date
- Sep 2009
- Posts
- 42
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
simply rails 2- still need some feedback on page 105
I am still trying to do the the practice exercise on page 105. I am using the the shovell prompt then I enter... class Author < ActiveRecord::Base, and it comes back that the syntax in incorrect. what am I doing wrong?
-
Oct 11, 2009, 21:35 #2
- Join Date
- Jan 2007
- Location
- Silicon Holler
- Posts
- 184
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
"Be kind, for everyone you meet is fighting a
hard battle." -Plato
-
Oct 11, 2009, 22:44 #3
- Join Date
- Sep 2009
- Posts
- 42
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I pasted what you sent me into the shovell prompt and it said syntax is incorrect still, any idea why?
-
Oct 12, 2009, 16:14 #4
- Join Date
- Jan 2007
- Location
- Silicon Holler
- Posts
- 184
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Type this first, then try the command again:
Code:ruby script/console
To exit the development environment and go back into the "shovell" directory, just type "exit"."Be kind, for everyone you meet is fighting a
hard battle." -Plato
-
Oct 14, 2009, 13:45 #5
- Join Date
- Sep 2009
- Posts
- 42
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
that worked, but the syntax that is given in the book didn't work even when I put a semi colon after the the word weblog. the book says enter this...
class Author < ActiveRecord::Base
has_one :weblog
end
what do you make of this?
-
Oct 14, 2009, 15:27 #6
- Join Date
- Jan 2007
- Location
- Silicon Holler
- Posts
- 184
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It looks like the author is just trying to get you to practice using the Rails console environment.
The code should work as long as you are in the Rails console - which you get by typing:
Code:ruby script/console
When you are actually building a Rails app, you won't build your models from within the console anyway - you will always have a file that your model resides in. The only thing you'll run from the console is the "ruby script/generate model" command. This will automatically create a file within the "Models" directory that will contain the class and allow you to make modifications to that file and add associations like "has_one", "belongs_to", etc.
I wouldn't let yourself get hung up on this if it's giving you problems. Sometimes the best thing to do is go on to the next section. To me, working with the files that are generated for you is a lot easier than trying to build models from within the console - maybe things will click better for you if you look ahead a little further. You can always come back to that section later."Be kind, for everyone you meet is fighting a
hard battle." -Plato
Bookmarks