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'
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.