Hi all,
Could any one help me how to edit all the timesheets at a time.
If i slect the month as december, i should get all teh timesheets from
the data base, I''m getting this one correctly, after getting this, i
should be able to edit these automatically all the timesheets.
See this is my controller::
def logic1
userId=@session[''user''][''id'']
user=User.find(userId)
#@timesheets =
Timesheet.find(:all,:conditions=>[''month(created_at)
= ?'', params[:timesheet]['':created_at(2i)''].to_i])
@timesheets = Timesheet.find_by_sql("select * from timesheets where
user_id=''#{userId}'' and
month(created_at)''#{params[:timesheet][''created_at(2i)''].to_i}''
and
year(created_at)''#{params[:timesheet][''created_at(1i)''].to_i}''")
@timesheets=Timesheet.find(@timesheets)
end
my rhtml file::
<%= link_to "Home", :action=>"index"%>
Total hours worked in
<strong><%=params[:timesheet][''created_at(2i)'']%></strong>th
month of
Year
<strong><%=params[:timesheet][''created_at(1i)'']%><strong>
<strong><%=@total%></strong> hours
<%= start_form_tag :action =>
''update'',:id=>@timesheets %>
<table border="1" bordercolor="black">
<tr>
<th>Created At</th>
<th>Project</th>
<th>Hours Worked</th>
<th>Remarks</th>
</tr>
<tr> <td><%= date_select ''timesheet'',
''created_at'' %></td>
<%@projects=Project.find_all%></td>
<td><%= collection_select("timesheet",
"project" , @projects,
"name", "name") %></td>
<td><%= text_field ''timesheet'',
''hours_worked'', "size" => 31
%></td><td >
<%= text_area ''timesheet'',
''remarks'' ,"cols" => 22, "rows"
=> 5 %></td>
</tr>
<tr> <td><%= date_select ''timesheet'',
''created_at'' %></td>
<%@projects=Project.find_all%>
<td><%= collection_select("timesheet",
"project" , @projects,
"name", "name") %></td>
<td><%= text_field ''timesheet'',
''hours_worked'', "size" => 31
%></td>
<td><%= text_area ''timesheet'',
''remarks'' ,"cols" => 22, "rows"
=> 5 %></td>
</tr>
</table>
<%= submit_tag "Create" %>
<%= end_form_tag %>
Thanks in Advance,
Harish
--
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
-~----------~----~----~----~------~----~------~--~---