New rails user - Trying to understand why console wont run save command

Hi Everyone,

I just found this forum today and I'm having trouble with a rails tutorial I'm working on. On all other rails console commands it runs when I hit enter such as:

">> subject.new_record? => true"

However when I try to save a record using:

subject = Subject.new(:name => "First Subject", :position => 1", :visible =>

true)

Nothing happens. I tried create as well. When I hit enter it just puts an enter and doesn't run the command which returns. Any clue what I'm doing wrong?

On all other rails console commands it runs when I hit enter such as:

">> subject.new_record? => true"

However when I try to save a record using:

subject = Subject.new(:name => "First Subject", :position => 1", :visible =>

true)

That won't save a record. It will only create an object. To save it as a database record, you need to do subject.save -- and that also assumes that the class inherits from ActiveRecord, you've created the table in the database, etc.

Nothing happens. I tried create as well. When I hit enter it just puts an enter and doesn't run the command which returns. Any clue what I'm doing wrong?

Does it do absolutely nothing, not even tell you something like:

  => #<Subject:0x00000100a218a8 name="dave", position="reclining", visible=true>

? That is indeed odd. Can you post the code of the class, at least the initializer?

-Dave

Subject.new only create a new object in memory, to persist in the database you should to use subject.save or directly Subject.create(:name => “First Subject”, :position => 1", :visible => true)

You've got an extra quote in there after :position...

wow. The quote was the issue. Unbelievable. Thanks. I'm back to cranking out this tutorial

The reason it did not do anything was because you had not entered a complete statement (the extra quote meant that the last stuff on the line appeared to be a quoted string) so it was waiting for you to enter the rest of the statement. I imagine it prompted you with a > or similar.

Colin