Hi: I''ve tackled this problem three seperate times with a couple of posts and still can''t get it to work. All I really want to do is grab a value in not-exactly date format and put it in a mysql database datetime column with a time of zero. The frustrating thing is that I''ve tried it in the console and it''s totally working. But when I go back to the DB, it''s just not there: @task = Task.new(params[:task]) @task.duedate = params[:task][:duedate] @task.save! Pretty simple, right? It''s not there. I also put it in a session variable just to make sure I''m actually getting the value from paras - no problem, it''s there: session[:duedate] = params[:task][:duedate] But still not in the DB. I''ve tried it a bunch of different ways, including trying a session variable @date = params[:task][:duedate] @task.duedate = @date That didn''t work. The really bad part - when I just try a string: @task.duedate = "04/03/2007" Again, nothing, even though in the console, I was able to get it to work. What the heck am I doing wrong? Any help you can give would be greatly appreciated! As you can see, I''m going nuts! Thanks in advance! Mike -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Try @task.duedate = "2007-04-03" On Feb 18, 2:34 pm, Mike Dershowitz <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi: > > I''ve tackled this problem three seperate times with a couple of posts > and still can''t get it to work. > > All I really want to do is grab a value in not-exactly date format and > put it in a mysql database datetime column with a time of zero. The > frustrating thing is that I''ve tried it in the console and it''s totally > working. But when I go back to the DB, it''s just not there: > > @task = Task.new(params[:task]) > @task.duedate = params[:task][:duedate] > @task.save! > > Pretty simple, right? It''s not there. I also put it in a session > variable just to make sure I''m actually getting the value from paras - > no problem, it''s there: > > session[:duedate] = params[:task][:duedate] > > But still not in the DB. I''ve tried it a bunch of different ways, > including trying a session variable > > @date = params[:task][:duedate] > @task.duedate = @date > > That didn''t work. The really bad part - when I just try a string: > > @task.duedate = "04/03/2007" > > Again, nothing, even though in the console, I was able to get it to > work. > > What the heck am I doing wrong? Any help you can give would be greatly > appreciated! As you can see, I''m going nuts! > > Thanks in advance! > > Mike > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Why are you setting the duedate separately? From your code, the :duedate field is in the :task hash, so if there''s a database column called duedate on the table task, it should work automatically. I would focus on the format of the date coming in. Are you letting the user type in any date they''d like? The the other respondent, MySQL expects dates in YYYY-MM-DD format. Mike Dershowitz wrote:> Hi: > > I''ve tackled this problem three seperate times with a couple of posts > and still can''t get it to work. > > All I really want to do is grab a value in not-exactly date format and > put it in a mysql database datetime column with a time of zero. The > frustrating thing is that I''ve tried it in the console and it''s totally > working. But when I go back to the DB, it''s just not there: > > @task = Task.new(params[:task]) > @task.duedate = params[:task][:duedate] > @task.save! > > Pretty simple, right? It''s not there. I also put it in a session > variable just to make sure I''m actually getting the value from paras - > no problem, it''s there: > > session[:duedate] = params[:task][:duedate] > > But still not in the DB. I''ve tried it a bunch of different ways, > including trying a session variable > > @date = params[:task][:duedate] > @task.duedate = @date > > That didn''t work. The really bad part - when I just try a string: > > @task.duedate = "04/03/2007" > > Again, nothing, even though in the console, I was able to get it to > work. > > What the heck am I doing wrong? Any help you can give would be greatly > appreciated! As you can see, I''m going nuts! > > Thanks in advance! > > Mike-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---