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
example schoolclass.save()
hope that makes sense and is the answer you were looking for.
Mark
On 3/8/06, Les Nightingill <lester@ix.netcom.com>
wrote:>
> 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 = Schoolclass.new
> end
>
> I wanted to initialize the object, so I added to the object creation
> statement as follows:
>
> @schoolclass = Schoolclass.new(:day=>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.) @schoolclass.day .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.) @schoolclass.day 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!
>
> Les
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
--------------------------------------------------------------------
I am Mark Daggett and I approve this message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060309/38f6d63d/attachment.html