[Locomotive-users] Stuck on first Locomotive attempt--help?
Mats Persson
mats at imediatec.co.uk
Wed Jun 7 20:50:46 GMT 2006
On 7 Jun 2006, at 21:13, David Matuszek wrote:
> 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
OK, this one is easy, and it's a mistake I've done as well before.
1. Before using the scaffold script OR the scaffold method in a
controller, you *must* have created the db table with the required
fields and so on.
So I think the correct workflow goes something like this:
-- run db:migrate to ensure that you can communicate with your db
-- script/generate model Student
-- edit the generated /db/migrations/001_create_students.rb file and
add your table fields. NB!! Use the Rails Migrations instead of SQL,
it's better in every way.
-- run rake db:migrate
-- and then run your script/generate scaffold Student
-- things should now be working just great ! (IF not, come back to me/
list)
The final and *most important* step ;-) is go visit this website
[ http://pragmaticprogrammer.com/titles/rails/index.html ] with your
creditcard in hand, and plonk down the US$23,50 for the 2nd edition
of "Agile Web Development with Rails". It is so worth your time and
money, just trust me :-)
You might also want to look at Ruby For Rails by David A. Black,
also a good point to start with.
Hope that will have helped you get going again
Kind regards,
Mats
----
"TextMate, coding with an incredible sense of joy and ease"
- www.macromates.com -
"RubyOnRails development done the Mac way"
- locomotive.raaum.org -
More information about the Locomotive-users
mailing list