Skip to content

Instantly share code, notes, and snippets.

@xenda
Created February 27, 2013 02:51
Show Gist options
  • Save xenda/5044573 to your computer and use it in GitHub Desktop.
Save xenda/5044573 to your computer and use it in GitHub Desktop.
# app/models/consult.rb
class Consult < ActiveRecord::Base
attrs_accesible :nota_ingreso_attributes
has_one :nota_ingreso
accepts_nested_attributes_for :nota_ingreso
end
# app/view/..
<%= form_for(@consult) do |f| %>
<%= link_to "Listado", :action => "list"%>
<%= f.submit "Actualizar" %>
<fieldset>
<legend align="left">Datos Personales</legend>
<td align="right"><label for="notaingreso">motivo de ingreso:</label></td>
<% f.fields_for :nota_ingreso do |ni| %>
<%= ni.text_area "motivo_ingreso", :class => "textinput_width", :size => "100x6" %>
<% end
</table>
</div>
</tr>
<% end %>
</table>
</fieldset>
</div>
# app/controllers/consults_controller.rb
class ConsultsController < ApplicationController
def update
@consult = Consult.find(params[:id])
@consult.update_attributes(params[:consult])
redirect_to "/"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment