Skip to content

Instantly share code, notes, and snippets.

Created November 27, 2008 05:29
Show Gist options
  • Save anonymous/29690 to your computer and use it in GitHub Desktop.
Save anonymous/29690 to your computer and use it in GitHub Desktop.
----------------MODELO---------------------
class Paciente < ActiveRecord::Base
belongs_to :usuario
has_many :resultados
end
----------------CONTROLADOR --------------------
class PacienteController < ApplicationController
def index
end
def crear
@paciente = Paciente.new(params[:paciente])
if @paciente.save
flash[:notice] = 'guardado jijiij'
end
end
def mostrar
@paciente = Paciente.find(:all)
end
def editar
end
def borrar
end
end
------------- VISTA crear----------------------------
<h1>Crear pacientes</h1>
<% form_for :paciente do |p| %>
<p>nombre<br />
<%= p.text_field :nombre %>
</p>
<p>
edad <br />
<%= p.text_field :edad %>
</p>
<p>
correo <br />
<%= p.text_field :correo %>
</p>
<p>
<%= p.submit "crear" %>
</p>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment