Advertisement
Guest User

Untitled

a guest
Apr 1st, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.24 KB | None | 0 0
  1. <form class="form-horizontal">
  2.  
  3. <form class="form-horizontal" action="/users/create" method="post">
  4.  
  5. <div class = "modal fade" id="signupform">
  6. <div class= "modal-dialog">
  7. <div class="modal-content">
  8. <div class="modal-header">
  9. <button type="button" class="close" data-dismiss="modal" aria-label=""><span>&times;</span>
  10. </button>
  11. <h4 class="modal-title">
  12. Sign Up
  13.  
  14. </h4>
  15.  
  16. </div>
  17. <div class="modal-body">
  18.  
  19. <form class="form-horizontal">
  20. <%= hidden_field_tag :authenticity_token, form_authenticity_token -%>
  21. <div class="form-group">
  22. <label class="col-md-4 col-md-offset-1">
  23. First Name
  24. </label>
  25. <div class="col-md-5">
  26. <input type="text" id="first_name_register" name="first_name" class="form-control input-sm">
  27. </div>
  28.  
  29. </div>
  30. <div class="form-group">
  31. <label class="col-md-4 col-md-offset-1">
  32. Last Name
  33. </label>
  34. <div class="col-md-5">
  35. <input type="text" id="last_name_register" name="last_name" class="form-control input-sm">
  36. </div>
  37.  
  38. </div>
  39. <div class="form-group">
  40. <label class="col-md-4 col-md-offset-1">
  41. Email
  42. </label>
  43. <div class="col-md-5">
  44. <input type="text" id="email_register" name="email" class="form-control input-sm">
  45. </div>
  46.  
  47. </div>
  48. <div class="form-group">
  49. <label class="col-md-4 col-md-offset-1">
  50. Username
  51. </label>
  52. <div class="col-md-5">
  53. <input type="text" id="username_register" name="username" class="form-control input-sm">
  54. </div>
  55.  
  56. </div>
  57. <div class="form-group">
  58. <label class="col-md-4 col-md-offset-1">
  59. Password
  60. </label>
  61. <div class="col-md-5">
  62. <input type="password" id="password_register" name="password" class="form-control input-sm">
  63. </div>
  64.  
  65. </div>
  66.  
  67. <div class="form-group">
  68. <label class="col-md-4 col-md-offset-1">
  69. Confirm Password
  70. </label>
  71. <div class="col-md-5">
  72. <input type="password" id="password_confirm_register" name="password_confirmation" class="form-control input-sm">
  73. </div>
  74.  
  75. </div>
  76.  
  77. <div class="form-group">
  78.  
  79. <div class="col-md-2 col-md-offset-8">
  80. <input type="submit" id = "registerButton" class="btn btn-success" value="Submit" >
  81. </div>
  82.  
  83. </div>
  84. </form>
  85.  
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90.  
  91. <script>
  92.  
  93. $(document.getElementById("registerButton")).click(function( event ) {
  94. event.preventDefault();
  95. $.ajax({
  96. url: "/users/create",
  97. type: "POST",
  98. data: {first_name : document.getElementById("first_name_register").value,
  99. last_name : document.getElementById("last_name_register").value,
  100. email : document.getElementById("email_register").value,
  101. password : document.getElementById("password_register").value,
  102. password_confirmation : document.getElementById("password_confirm_register").value
  103. },
  104. contentType: 'json',
  105. success: function(response) {
  106. console.log(response);
  107. }
  108.  
  109. });
  110. });
  111. </script>
  112.  
  113. def create
  114.  
  115. @user = User.new(:username => params[:username], :email => params[:email],
  116. :password => params[:password], :password_confirmation => params[:password_confirmation],
  117. :first_name => params[:first_name], :last_name => params[:last_name])
  118. if @user.save
  119. #flash[:notice] = "You signed up successfully"
  120. #flash[:color]= "valid"
  121. else
  122. #flash[:notice] = "Form is invalid"
  123. #flash[:color]= "invalid"
  124. end
  125. render json: @user.to_json
  126.  
  127. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement