I'm trying to save a value collected from datepicker (Jquery) to my database. The issue is, it saves correctly sometimes and other times when I change nothing in the code it returns NULL.
CODE
<%= simple_form_for (@vacay),
:url => url_for(:action => 'setVacay', :controller => 'employees'),
:method => 'post' do |v| %>
<%= v.error_notification %>
<%= v.text_field :dateFrom, :value_method => @vacay %> to <%= v.text_field :dateUntil, :value_method => @vacay %>
Controller
def setVacay
@user = current_user
@vacay = Vacay.new(params[:vacay])
@vacay.save
flash[:success] = "Created vacation request"
redirect_to :controller => "users", :action => "allemploy"
end
IRB Log
1) Parameters: {"utf8"=>"✓", "authenticity_token"=>"b4Uzq7CQvD8qnIBfnr/GmaMCxNjbINxd8CMskmyirPI=", "vacay"=>{"dateFrom"=>"09/20/2011", "dateUntil"=>"09/25/2011", "brought_forward"=>"5", "employee_id"=>"1", "user_id"=>"1"}, "commit"=>"Create Vacay"} User Load (0.4ms) SELECT "users".* FROM "users" WHERE ("users"."id" = 1) LIMIT 1 AREL (0.4ms) INSERT INTO "vacays" ("brought_forward", "dateFrom", "dateUntil", "user_id", "employee_id", "sumVacay", "created_at", "updated_at") VALUES (5, NULL, NULL, 1, 1, NULL, '2011-09-20 01:25:36.804428', '2011-09-20 01:25:36.804428')
2.) When tried at another time. Sometimes it saves params before then doesnt save after or vica versa
AREL (0.4ms) INSERT INTO "vacays" ("brought_forward", "dateFrom", "dateUntil", "user_id", "employee_id", "sumVacay", "created_at", "updated_at") VALUES (5, '2011-01-09', '2011-02-09', 1, 1, NULL, '2011-09-20 01:32:54.097928', '2011-09-20 01:32:54.097928') Redirected to http://localhost:3000/all Completed 302 Found in 336ms