Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form class="form-horizontal">
- <form class="form-horizontal" action="/users/create" method="post">
- <div class = "modal fade" id="signupform">
- <div class= "modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label=""><span>×</span>
- </button>
- <h4 class="modal-title">
- Sign Up
- </h4>
- </div>
- <div class="modal-body">
- <form class="form-horizontal">
- <%= hidden_field_tag :authenticity_token, form_authenticity_token -%>
- <div class="form-group">
- <label class="col-md-4 col-md-offset-1">
- First Name
- </label>
- <div class="col-md-5">
- <input type="text" id="first_name_register" name="first_name" class="form-control input-sm">
- </div>
- </div>
- <div class="form-group">
- <label class="col-md-4 col-md-offset-1">
- Last Name
- </label>
- <div class="col-md-5">
- <input type="text" id="last_name_register" name="last_name" class="form-control input-sm">
- </div>
- </div>
- <div class="form-group">
- <label class="col-md-4 col-md-offset-1">
- Email
- </label>
- <div class="col-md-5">
- <input type="text" id="email_register" name="email" class="form-control input-sm">
- </div>
- </div>
- <div class="form-group">
- <label class="col-md-4 col-md-offset-1">
- Username
- </label>
- <div class="col-md-5">
- <input type="text" id="username_register" name="username" class="form-control input-sm">
- </div>
- </div>
- <div class="form-group">
- <label class="col-md-4 col-md-offset-1">
- Password
- </label>
- <div class="col-md-5">
- <input type="password" id="password_register" name="password" class="form-control input-sm">
- </div>
- </div>
- <div class="form-group">
- <label class="col-md-4 col-md-offset-1">
- Confirm Password
- </label>
- <div class="col-md-5">
- <input type="password" id="password_confirm_register" name="password_confirmation" class="form-control input-sm">
- </div>
- </div>
- <div class="form-group">
- <div class="col-md-2 col-md-offset-8">
- <input type="submit" id = "registerButton" class="btn btn-success" value="Submit" >
- </div>
- </div>
- </form>
- </div>
- </div>
- </div>
- </div>
- <script>
- $(document.getElementById("registerButton")).click(function( event ) {
- event.preventDefault();
- $.ajax({
- url: "/users/create",
- type: "POST",
- data: {first_name : document.getElementById("first_name_register").value,
- last_name : document.getElementById("last_name_register").value,
- email : document.getElementById("email_register").value,
- password : document.getElementById("password_register").value,
- password_confirmation : document.getElementById("password_confirm_register").value
- },
- contentType: 'json',
- success: function(response) {
- console.log(response);
- }
- });
- });
- </script>
- def create
- @user = User.new(:username => params[:username], :email => params[:email],
- :password => params[:password], :password_confirmation => params[:password_confirmation],
- :first_name => params[:first_name], :last_name => params[:last_name])
- if @user.save
- #flash[:notice] = "You signed up successfully"
- #flash[:color]= "valid"
- else
- #flash[:notice] = "Form is invalid"
- #flash[:color]= "invalid"
- end
- render json: @user.to_json
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement