the.masch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Mar-27 20:04 UTC
[]Help with form_for
I have this rhtml, that generate a table with the object @evaluations
filled it before. The problem is that i need to get those text_field
with the data loaded, but instead it'' filled all text_field whit the
last @evaluation.
What i am doing wrong?
<% form_for( @evaluations ) do |f| %>
<table>
<tr>
<th>Student</th>
<th>Commission</th>
<th>Id</th>
<th>Parcial 1</th>
<th>Parcial 2</th>
<th>Final</th>
</tr>
<% for evaluation in @evaluations %>
<%= evaluation.id%>
<tr>
<td><%=h evaluation.student.fistName %></td>
<td><%=h evaluation.commission.code %></td>
<td><%=f.text_field(:id, :size => 2) %></td>
<td><%=f.text_field(:first_evaluation, :size => 2)
%></td>
<td><%=f.text_field(:second_evaluation, :size => 2)
%></td>
<td><%=f.text_field(:final_evaluation, :size => 2)
%></td>
<td><%= link_to ''Show'', evaluation
%></td>
<td><%= link_to ''Edit'',
edit_evaluation_path(evaluation) %></td>
<td><%= link_to ''Destroy'', evaluation, :confirm
=> ''Are you
sure?'', :method => :delete %></td>
</tr>
<% end %>
</table>
<p>
<%= f.submit "Update" %>
</p>
<% end %>
Thanks you much for your help.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
the.masch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Mar-27 20:05 UTC
Help with form_for
I have this rhtml, that generate a table with the object @evaluations
filled it before. The problem is that i need to get those text_field
with the data loaded, but instead it'' filled all text_field whit the
last @evaluation.
What i am doing wrong?
<% form_for( @evaluations ) do |f| %>
<table>
<tr>
<th>Student</th>
<th>Commission</th>
<th>Id</th>
<th>Parcial 1</th>
<th>Parcial 2</th>
<th>Final</th>
</tr>
<% for evaluation in @evaluations %>
<%= evaluation.id%>
<tr>
<td><%=h evaluation.student.fistName %></td>
<td><%=h evaluation.commission.code %></td>
<td><%=f.text_field(:id, :size => 2) %></td>
<td><%=f.text_field(:first_evaluation, :size => 2)
%></td>
<td><%=f.text_field(:second_evaluation, :size => 2)
%></td>
<td><%=f.text_field(:final_evaluation, :size => 2)
%></td>
<td><%= link_to ''Show'', evaluation
%></td>
<td><%= link_to ''Edit'',
edit_evaluation_path(evaluation) %></td>
<td><%= link_to ''Destroy'', evaluation, :confirm
=> ''Are you
sure?'', :method => :delete %></td>
</tr>
<% end %>
</table>
<p>
<%= f.submit "Update" %>
</p>
<% end %>
Thanks you much for your help.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
On 27 Mar 2008, at 20:04, the.masch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > I have this rhtml, that generate a table with the object @evaluations > filled it before. The problem is that i need to get those text_field > with the data loaded, but instead it'' filled all text_field whit the > last @evaluation. > What i am doing wrong? >form_for binds a form builder to one particular object, so trying to use it to display text_fields for multiple objects isn''t going to work. If you''re set on using a single form, you might want to look at fields_for (fields_for gives you a form builder much like what you would get from form_for but just generates the input tags. Fred> <% form_for( @evaluations ) do |f| %> > > <table> > <tr> > <th>Student</th> > <th>Commission</th> > <th>Id</th> > <th>Parcial 1</th> > <th>Parcial 2</th> > <th>Final</th> > </tr> > > <% for evaluation in @evaluations %> > <%= evaluation.id%> > <tr> > <td><%=h evaluation.student.fistName %></td> > <td><%=h evaluation.commission.code %></td> > > <td><%=f.text_field(:id, :size => 2) %></td> > <td><%=f.text_field(:first_evaluation, :size => 2) %></td> > <td><%=f.text_field(:second_evaluation, :size => 2) %></td> > <td><%=f.text_field(:final_evaluation, :size => 2) %></td> > > <td><%= link_to ''Show'', evaluation %></td> > <td><%= link_to ''Edit'', edit_evaluation_path(evaluation) %></td> > <td><%= link_to ''Destroy'', evaluation, :confirm => ''Are you > sure?'', :method => :delete %></td> > </tr> > <% end %> > </table> > > <p> > <%= f.submit "Update" %> > </p> > <% end %> > > > Thanks you much for your help. > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks,,,!
I founded it text_field_tag, i don''t know if is the best way, but in
the
controller i used:
first_evaluation = params[:first_evaluation]
Then i fill the values with those values.In the view i used:
<%= text_field_tag("first_evaluation[]",
evaluation.first_evaluation, :size
=> 2 ). What do you thing about it?
Sallu2...
On Thu, Mar 27, 2008 at 8:36 PM, Frederick Cheung <
frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>
> On 27 Mar 2008, at 20:04, the.masch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
wrote:
>
> >
> > I have this rhtml, that generate a table with the object @evaluations
> > filled it before. The problem is that i need to get those text_field
> > with the data loaded, but instead it'' filled all text_field
whit the
> > last @evaluation.
> > What i am doing wrong?
> >
> form_for binds a form builder to one particular object, so trying to
> use it to display text_fields for multiple objects isn''t going to
> work. If you''re set on using a single form, you might want to look
at
> fields_for (fields_for gives you a form builder much like what you
> would get from form_for but just generates the input tags.
>
> Fred
>
> > <% form_for( @evaluations ) do |f| %>
> >
> > <table>
> > <tr>
> > <th>Student</th>
> > <th>Commission</th>
> > <th>Id</th>
> > <th>Parcial 1</th>
> > <th>Parcial 2</th>
> > <th>Final</th>
> > </tr>
> >
> > <% for evaluation in @evaluations %>
> > <%= evaluation.id%>
> > <tr>
> > <td><%=h evaluation.student.fistName %></td>
> > <td><%=h evaluation.commission.code %></td>
> >
> > <td><%=f.text_field(:id, :size => 2) %></td>
> > <td><%=f.text_field(:first_evaluation, :size => 2)
%></td>
> > <td><%=f.text_field(:second_evaluation, :size => 2)
%></td>
> > <td><%=f.text_field(:final_evaluation, :size => 2)
%></td>
> >
> > <td><%= link_to ''Show'', evaluation
%></td>
> > <td><%= link_to ''Edit'',
edit_evaluation_path(evaluation) %></td>
> > <td><%= link_to ''Destroy'', evaluation,
:confirm => ''Are you
> > sure?'', :method => :delete %></td>
> > </tr>
> > <% end %>
> > </table>
> >
> > <p>
> > <%= f.submit "Update" %>
> > </p>
> > <% end %>
> >
> >
> > Thanks you much for your help.
> > >
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---