Forum: Ruby on Rails very basic newbie question!

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
A0eee794e60f2555d410b8accb674ffb?d=identicon&s=25 Les Nightingill (lazylester)
on 2006-03-09 01:56
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!

51f10739fd903d3b57561a15e4598954?d=identicon&s=25 M Daggett (Guest)
on 2006-03-09 19:03
(Received via mailing list)
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.
This topic is locked and can not be replied to.