[Locomotive-users] Stuck on first Locomotive attempt--help?
David Matuszek
matuszek at cis.upenn.edu
Wed Jun 7 20:13:14 GMT 2006
I'm trying to learn Ruby and Rails simultaneously. The only
Locomotive documentation I've found is the seriously out of
date movie, and I've been trying to adapt it.
I'm OK up to the point where I run
ruby script/generate scaffold Student
this gives the error
Before updating scaffolding from new DB schema, try creating a
table for your model (Student)
and the browser page says
ActiveRecord::StatementInvalid in StudentsController#list
In the full trace, I find the line
#{RAILS_ROOT}/app/controllers/students_controller.rb:12:in `list'
and lines 11-13 in students_controller.rb are:
def list
@student_pages, @students = paginate :students, :per_page => 10
end
If I understood the Ruby a bit better, this would probably tell me
exactly what I need to do. As it is, I'm appealing for help.
Advice is welcome, preferably dumbed-down so a Ruby novice like
myself can understand it.
What follows is a step-by-step listing of exactly what I think
I've done so far, in case that's needed.
Advance thanks!!!
--Dave Matuszek
-----------------------------------------------------------------
1. Downloaded Locomotive from [[http://locomotive.raaum.org].
2. Ran by double-clicking the Locomotive icon.
3. Applications -> Create New...
Application name: myapp
Application directory: ~/Desktop
Framework: Rails 1.1.2.
4. With 'myapp 3000' selected, clicked green 'Run' button.
5. In browser, went to http://localhost:3000
This displayed a welcome page.
6. Applications -> Open Terminal (don't open any other way!)
Entered the command: ruby script/generate controller say
This displayed several 'exists' and 'creates' lines.
7. Used TextWrangler? to open
~/Desktop/myapp/app/controllers/say_controller.rb
and added the lines
->def hello
->end
and saved the file.
8. Then I created a file containing
<html>
<body>
<h1>Hello Dr. Dave!</h1>
</body>
</html>
and saved it as
~/Desktop/myapp/app/views/hello.rhtml
9. In a browser, I went to http://localhost:3000/say/hello
and saw:
Hello Dr. Dave!
10. Then I created a file containing
create table students (
id INTEGER PRIMARY KEY,
name VARCHAR(100));
and saved it as
~/Desktop/myapp/db/schema.sql
11. In the Terminal window:
cd ~/Desktop/myapp/db
sqlite mydb < schema.sql
This created a binary file named 'mydb'.
12. Edited the file ~/Desktop/myapp/config/database.yml; changed:
development:
adapter: mysql
database: myapp_development
username: root
password:
host: localhost
to
development:
adapter: sqlite
database: db/mydb
host: localhost
Also changed adapter and database under 'test:' accordingly.
13. In the Terminal window:
cd ~/Desktop/myapp
ruby script/generate scaffold Student
This should generate many 'exists', 'creates', and possibly
'identical' lines, but no 'error' lines.
More information about the Locomotive-users
mailing list