Guest User

Untitled

a guest
Feb 21st, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. ----------------MODELO---------------------
  2.  
  3. class Paciente < ActiveRecord::Base
  4. belongs_to :usuario
  5. has_many :resultados
  6. end
  7.  
  8. ----------------CONTROLADOR --------------------
  9.  
  10. class PacienteController < ApplicationController
  11. def index
  12. end
  13.  
  14. def crear
  15. if request.post? # aca es para que no haga lo mismo con el get sino solo con el POST
  16. @paciente = Paciente.new(params[:paciente])
  17. if @paciente.save
  18. flash[:notice] = 'guardado jijiij'
  19. end
  20. end
  21. end
  22.  
  23. def mostrar
  24. @paciente = Paciente.find(:all)
  25. end
  26.  
  27. def editar
  28. end
  29.  
  30. def borrar
  31. end
  32.  
  33. end
  34.  
  35. ------------- VISTA crear----------------------------
  36.  
  37. <h1>Crear pacientes</h1>
  38. <% form_for :paciente do |p| %>
  39. <p>nombre<br />
  40. <%= p.text_field :nombre %>
  41. </p>
  42. <p>
  43. edad <br />
  44. <%= p.text_field :edad %>
  45. </p>
  46. <p>
  47. correo <br />
  48. <%= p.text_field :correo %>
  49. </p>
  50. <p>
  51. <%= p.submit "crear" %>
  52. </p>
  53. <% end %>
Add Comment
Please, Sign In to add comment