Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------MODELO---------------------
- class Paciente < ActiveRecord::Base
- belongs_to :usuario
- has_many :resultados
- end
- ----------------CONTROLADOR --------------------
- class PacienteController < ApplicationController
- def index
- end
- def crear
- if request.post? # aca es para que no haga lo mismo con el get sino solo con el POST
- @paciente = Paciente.new(params[:paciente])
- if @paciente.save
- flash[:notice] = 'guardado jijiij'
- end
- 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 %>
Add Comment
Please, Sign In to add comment