Les Nightingill wrote:> I''ve got:
>
> def new
> @schoolclass = Schoolclass.new(:day=>1,
:start_time=>"2006:01:01
> 00:00:00, :description=>"enter description here")
> breakpoint()
> end
>
> after the breakpoint, I can @schoolclass.inspect and see the
> @schoolclass attributes, however @schoolclass.day, @schoolclass[:day]
> and @schoolclass["day"] all return NIL.
>
> what am I doing wrong?
1) Not sure if the typo is in this posting, or in the code, but you are
missing a closing quote after the 00:00:00.
2) is day an integer field in the schema ? If its a string, you''ll
need
to quote it.
With a migration of:
create_table :schoolclasses do |t|
t.column :day, :integer
t.column :start_time, :datetime
t.column :description, :string
end
That code above (with the quote added) works for me in console, so I
assume the datetime format is ok.
>> @sc = Schoolcass.new(:day => 1, :start_time => "2006:01:01
00:00:00", :description => "ddd")
=> #<Schoolclass:0x257fee4 @new_record=true,
@attributes={"description"=>"ddd", "day"=>1,
"start_time"=>"2006:01:01
00:00:00"}>>>
A.
--
Posted via http://www.ruby-forum.com/.