I am trying to update a leave but the update does not work. Please let
me know where I am making the mistake.(Looked in to the log, id in the
update SQL statment shows NULL)

View

<h1>Editing Leaves</h1>
<% form_for :leaves, @leaves, :url => { :controller =>
"leaves", :action => "update" } do |f| %>
   <%= f.text_field :id%>
    <b>Leave Type</b>
    <%= f.text_field :LEAVE_TYPE %><br>

<b>FROM_DATE</b>
    <%= f.text_field :FROM_DATE %><br>

<b>TO Date</b>
    <%= f.text_field :TO_DATE %><br>

<b>Phone Number</b>
    <%= f.text_field :PHONE_NUMBER %><br>

<b>Address</b>
    <%= f.text_field :ADDRESS %><br>



<b>Reason for Leave</b>
    <%= f.text_area :REASON_FOR_LEAVE %><br>

    <%= f.submit "update" %>

<% end %>
<%= error_messages_for :leaves %>

Controller's update method
def update
    @leaves=Leave.find(params[:id])
    if @leaves.update_attributes(params[:leave])
        #~ puts(@leaves.ID)
        flash[:notice] = 'Leave was successfully updated.'
         redirect_to :action => 'show', :id => @leaves.ID
    else
    render :action => 'edit'
     end
   end

I looked in to the log and looks like the id in update statement is
going NULL what could be the problem for this and how can I fix this.

 [0mSELECT * FROM `leaves` WHERE (`leaves`.`id` = '2')  [0m
   [4;36;1mSQL (0.000000) [0m    [0;1mBEGIN [0m
   [4;35;1mLeave Update (0.000000) [0m    [0mUPDATE `leaves` SET
`FROM_DATE` = '2008-11-05', `REASON_FOR_CANCELLATION` = NULL, `BACKUP`
= NULL, `EMP_ID` = 90268, `TO_DATE` = '2008-11-09', `ADDRESS` = NULL,
`MGR_EMP_ID` = 90000, `MANAGER_COMMENTS` = NULL, `REASON_FOR_LEAVE` =
NULL, `LEAVE_TYPE` = 'leave', `ID` = 2, `APPLIED_ON_DATE` =
'2008-09-15', `PHONE_NUMBER` = NULL, `LEAVE_STATUS` = 'PENDING' WHERE
`id` = NULL

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to