Very basic newbie question!


Bringing up (trying!) my first rails app… no OO experience

the scaffold generator automatically creates new activerecord objects
for the create/edit form using:

def new
@schoolclass =

I wanted to initialize the object, so I added to the object creation
statement as follows:

@schoolclass =>1, :start_time=>"2006:01:01
00:00:00, :description=>“enter description here”)

I was expecting that I could access the attributes of @schoolclass with
(e.g.) .A breakpoint right after the object creation
allows me to see the initialized attributes using @schoolclass.inspect,
BUT when I look at individual attribues using (e.g.) or
@schoolclass[:day] or @schoolclass[“day”] , they are all NIL.

What am I not seeing here? This exactly follows the example in the
ActiveRecord::Base documentation! How can I access the initialized
object attributes?

thanks in advance for any light you can shed!



hi les
You may want to try schoolclass.create() instead of new() because new
doesn’t store the record until you explicitly call the save function for

hope that makes sense and is the answer you were looking for.