# Help: @album.release\_date not coming out in view?

**URL:** <https://www.ruby-forum.com/t/help-album-release-date-not-coming-out-in-view/86057>\
**Category:** Rails\
**Created:** [February 19, 2007, 2:02pm UTC](https://www.ruby-forum.com/t/help-album-release-date-not-coming-out-in-view/86057 "2007-02-19T14:02:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [February 19, 2007, 2:02pm UTC](https://www.ruby-forum.com/t/help-album-release-date-not-coming-out-in-view/86057/1 "2007-02-19T14:02:43Z")

</div>

Hi everyone,

I need help.

I have a table called albums with various fields. One of them, the  
one I’m having problems with, is release\_date datetime. I generated a  
model for Album, too, but currently there’s nothing in it.

I have a controller, called Public, that has, among other things:

def create  
@album = Album.new  
@album.title = ‘Aftermath’  
@album.artist = ‘The Rolling Stones’  
@album.release\_date = ‘1967-01-01’  
@album.genre = ‘Rock’

```
#@album.save

```

end

In my view, when I do a \<%= debug(@album) %\>, I get

— !ruby/object:Album  
attributes:  
artist: The Rolling Stones  
title: Aftermath  
genre: Rock  
release\_date: “1967-01-01”  
new\_record: true

\*Note, I also tried “1967-01-01 12:00:00” but I got this error when  
trying to do a @album.save (Mysql::Error: #22007Incorrect datetime  
value: ‘1967-01-01T12:00:00Z’).

When I try to print out each attibute manually (calling @album.artist,  
@album.genre, etc), I get:

ID -  
Title - Aftermath  
Artist - The Rolling Stones  
Genre - Rock  
Date -

Of course, there’s no ID since it hasn’t been saved into the database  
yet. But date…?

Here’s my code to trace out the variables:

```
<% if @album != nil -%>
  ID - <%= @album.id %> <br />
  Title - <%= @album.title %> <br />
  Artist - <%= @album.artist %><br />
  Genre - <%= @album.genre %><br />
  Date - <%= @album.release_date %><br />
<% else -%>
  No record found.
<% end -%>

```

I’m stuck :o I need to be able to save this into the database. I’ve  
searched other places about the error I get when trying to save, which  
is “Mysql::Error: #23000Column ‘release\_date’ cannot be null”, but I  
haven’t found anything that solves my problem.

## Thanks!

Ramon Miguel M. Tayag

---

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [February 19, 2007, 3:15pm UTC](https://www.ruby-forum.com/t/help-album-release-date-not-coming-out-in-view/86057/2 "2007-02-19T15:15:52Z")

</div>

Try putting a full date string and see if that solves your problem.

@album.release\_date = ‘1967-01-01 12:00:00’

If it’s defined as a datetime field, SQL will want both the date and  
time and may or may not assume the time as midnight if you don’t  
supply it.

HTH,  
Kevin S.

---

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [February 19, 2007, 3:15pm UTC](https://www.ruby-forum.com/t/help-album-release-date-not-coming-out-in-view/86057/3 "2007-02-19T15:15:51Z")

</div>

> I’m stuck :o I need to be able to save this into the database. I’ve  
> searched other places about the error I get when trying to save, which  
> is “Mysql::Error: #23000Column ‘release\_date’ cannot be null”, but I  
> haven’t found anything that solves my problem.

This maybe isn’t helpful… But, have you tried debugging it with:  
@album.release\_date = Time.now

---

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [February 19, 2007, 3:52pm UTC](https://www.ruby-forum.com/t/help-album-release-date-not-coming-out-in-view/86057/4 "2007-02-19T15:52:56Z")

</div>

Kevin,

Yup, I’ve tried that, too. See the section:

# \*Note, I also tried “1967-01-01 12:00:00” but I got this error when trying to do a @album.save (Mysql::Error: #22007Incorrect datetime value: ‘1967-01-01T12:00:00Z’).

Toby, I’ll have to get back to you on that 🙂 I’m currently not able  
to check it out.

Thanks!

On 2/19/07, Kevin S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Kevin S.  
> –  
> Ramon Miguel M. Tayag

---

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [February 19, 2007, 4:04pm UTC](https://www.ruby-forum.com/t/help-album-release-date-not-coming-out-in-view/86057/5 "2007-02-19T16:04:57Z")

</div>

Oh my gosh! No wonder you name sounded familiar…

It’s your tutorial in Lynda I’m following 🙂 I was running it on a  
Windows machine but now I’m trying it on FC6 (took me a week to put  
the server up). I’ll update you on how it goes.

On 2/19/07, Kevin S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Kevin S.  
> –  
> Ramon Miguel M. Tayag

---

<div class="post-metadata">

**Author:** ![ramontayag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c6cbf5/32.png) [@ramontayag](https://www.ruby-forum.com/u/ramontayag)\
**Post date:** [February 19, 2007, 4:15pm UTC](https://www.ruby-forum.com/t/help-album-release-date-not-coming-out-in-view/86057/6 "2007-02-19T16:15:59Z")

</div>

Well, it seems to be running just fine on Linux :o

On 2/19/07, Ramon Miguel M. Tayag [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Oh my gosh! No wonder you name sounded familiar…
> 
> It’s your tutorial in Lynda I’m following 🙂 I was running it on a  
> Windows machine but now I’m trying it on FC6 (took me a week to put  
> the server up). I’ll update you on how it goes.

–  
Ramon Miguel M. Tayag
