Hi everyone here,
I try to use a check_box helper but it keeps flowing an error to my face.
Currently there are 2 tables : a table work_times has field: id,
check_in,check_out, lunch,user_id, signed (signed =0 or 1),
in view''s sign.rhtml, I like to pulls out a series of work_table
records from this work_times table and verify if each record''s signed
column is 0 or 1.
user can click or unclick the check box of the signed column (he can save more
than one) and save it to active record after pressing submit button. The menu
has something I think it''s related that reads
"If the object name contains square brackets the id for the object will be
inserted. Example:
<%= textfield "person[]", "name" %>
…becomes:
<input type="text" id="person_<%= @person.id
%>_name" name="person[<%= @person.id %>][name]"
value="<%= @person.name %>" />
If the helper is being used to generate a repetitive sequence of similar form
elements, for example in a partial used by render_collection_of_partials, the
"index" option may come in handy. Example:
<%= text_field "person", "name", "index"
=> 1 %>"
this is the code. Please kindly let me know what mistake I have made.
<h1>Report review</h1>
<form action="sign_update" method="post">
<table border ="1">
<tr>
<th>Check in </th>
<th>Check out</th>
<th>Lunch hour</th>
<th>Signed</th>
</tr>
<%=form_tag :action=>''sign_update'',
:id=>@current_user%>
<% for work_time in @work_times %>
<% time_in = work_time.check_in %>
<% time_out = work_time.check_out %>
<% lunch_time = work_time.lunch %>
<tr valign="top">
<td width="30%"><%= time_in.strftime("%y-%m-%d
%H:%M") %></td>
<td width="30%"><%= time_out.strftime("%y-%m-%d
%H:%M") %></td>
<td width="20%"><%=
lunch_time.strftime("%H:%M") %></td>
<td align="center"><%=check_box "work_time[]",
"signed"%></td>
<%= hidden_field ("work_time[][signed]","0")%>
</tr>
<% end %>
</table>
<input type="submit" value="Submit signature">
<%=end_form_tag%>
<%= button_to ''Back'', :action =>
''report'', :id=>session[:user].id %>
error message is WARNING: You have a nil object when you probably
didn''t expect it! Odds are you
want an instance of ActiveRecord::Base instead.
Look in the callstack to see where you''re working with an object that
could be nil.
Investigate your methods and make sure the object is what you expect.
Thank you very much for any suggestions.
sammy
---------------------------------
DO YOU YAHOO!?
雅虎邮箱超强增值服务-2G超大空间、pop3收信、无限量邮件提醒
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails