0

I had a fully functioning registration form. After styling (e.g downloading a template's html/css/js and placing into my app to make the page look better):

1) My registration page stopped working. If I press submit, nothing happens.

  • I've referenced this question: Rails form_for submit button not working which said to check for any syntax errors (which I believe I don't have)
  • I also read about Javascript caching potentially being the issue. The two SO questions I read talked about e.preventDefault() method in bootstrap.js but removing these didn't do anything for me. Not sure if I removed the correct thing?

Here is the css unique to the template I'm using:

/*!
 * Start Bootstrap - Business Casual Bootstrap Theme (http://startbootstrap.com)
 * Code licensed under the Apache License v2.0.
 * For details, see http://www.apache.org/licenses/LICENSE-2.0.
 */

body {
    font-family: "Open Sans","Helvetica Neue",Helvetica,Arial,sans-serif;
    background: url('bg.jpg') no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    background-size: cover;
    -o-background-size: cover;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    text-transform: uppercase;
    font-family: "Josefin Slab","Helvetica Neue",Helvetica,Arial,sans-serif;
    font-weight: 700;
    letter-spacing: 1px;
}

p {
    font-size: 1.25em;
    line-height: 1.6;
    color: #000;
}

hr {
    max-width: 400px;
    border-color: #999999;
}

.brand,
.address-bar {
    display: none;
}

.navbar-brand {
    text-transform: uppercase;
    font-weight: 900;
    letter-spacing: 2px;
}

.navbar-nav {
    text-transform: uppercase;
    font-weight: 400;
    letter-spacing: 3px;
}

.img-full {
    min-width: 100%;
}

.brand-before,
.brand-name {
    text-transform: capitalize;
}

.brand-before {
    margin: 15px 0;
}

.brand-name {
    margin: 0;
    font-size: 4em;
}

.tagline-divider {
    margin: 15px auto 3px;
    max-width: 250px;
    border-color: #999999;
}

.box {
    margin-bottom: 20px;
    padding: 30px 15px;
    background: #fff;
    background: rgba(255,255,255,0.9);
}

.intro-text {
    text-transform: uppercase;
    font-size: 1.25em;
    font-weight: 400;
    letter-spacing: 1px;
}

.img-border {
    float: none;
    margin: 0 auto 0;
    border: #999999 solid 1px;
}

.img-left {
    float: none;
    margin: 0 auto 0;
}

footer {
    background: #fff;
    background: rgba(255,255,255,0.9);
}

footer p {
    margin: 0;
    padding: 50px 0;
}

@media screen and (min-width:768px) {
    .brand {
        display: inherit;
        margin: 0;
        padding: 30px 0 10px;
        text-align: center;
        text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
        font-family: "Josefin Slab","Helvetica Neue",Helvetica,Arial,sans-serif;
        font-size: 5em;
        font-weight: 700;
        line-height: normal;
        color: #fff;
    }

    .top-divider {
        margin-top: 0;
    }

    .img-left {
        float: left;
        margin-right: 25px;
    }

    .address-bar {
        display: inherit;
        margin: 0;
        padding: 0 0 40px;
        text-align: center;
        text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
        text-transform: uppercase;
        font-size: 1.25em;
        font-weight: 400;
        letter-spacing: 3px;
        color: #fff;
    }

    .navbar {
        border-radius: 0;
    }

    .navbar-header {
        display: none;
    }

    .navbar {
        min-height: 0;
    }

    .navbar-default {
        border: none;
        background: #fff;
        background: rgba(255,255,255,0.9);
    }

    .nav>li>a {
        padding: 35px;
    }

    .navbar-nav>li>a {
        line-height: normal;
    }

    .navbar-nav {
        display: table;
        float: none;
        margin: 0 auto;
        table-layout: fixed;
        font-size: 1.25em;
    }
}

@media screen and (min-width:1200px) {
    .box:after {
        content: '';
        display: table;
        clear: both;
    }
}

In my routes file, I do have

devise_for :users 

and this is my user registration page new.html.erb

<h2>Sign up</h2>

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
  <%= devise_error_messages! %>
   <div class="row">
            <div class="box">
                <div class="col-lg-12">
                    <hr>
                    <h2 class="intro-text text-center">Sign up form</h2>
                    <hr>
                        <div class="row">
                            <div class="form-group col-lg-3">
                                <%= f.label :email %>
                                <%= f.email_field :email, autofocus: true, class: "form-control", required: true %>
                            </div>
                            <div class="form-group col-lg-3">
                                <%= f.label :phone_number %> (In the form: 123456789)
                                <%= f.text_field :phone_number, autofocus: true, class: "form-control", required: true %>
                            </div>
                            <div class="form-group col-lg-3">
                                <%= f.label :password %>
                                <%= f.password_field :password, class: "form-control", required: true %>
                            </div>
                            <!-- <div class="clearfix"></div> -->
                            <div class="form-group col-lg-3">
                                <%= f.label :password_confirmation %>
                                <%= f.password_field :password_confirmation, class: "form-control", required: true %>
                            </div>
                            <div class="form-group col-lg-12">
                                <%= f.submit "Sign up", class: "btn btn-default" %>
                            </div>
                        </div>
                    </div>
              </div>
      </div>
<% end %>
<%= render "devise/shared/links" %> 

This page is showing up fine, but nothing happens when I press the submit button.

Here is my application.js

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs 
//= require turbolinks
//= require bootstrap-sprockets
//= require rails.validations
//= require_tree .

And my application.css.scss

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any styles
 * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
 * file per style scope.
 *

 */
@import "bootstrap-sprockets";
@import "bootstrap";
@import "font-awesome-sprockets";
@import "font-awesome";
@import "business-casual";
@import "bootstrap-theme";


#logo {
    font-size: 26px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: -1px;
    padding: 15px 0;
    a {
        color: #2F363E;
    }
}

Any ideas?

Edit to include information based on comments: Starting my local server via rails s. Javascript console throws one error:

[Error] Failed to load resource: the server responded with a status of 500 (Internal Server Error) (bootstrap-theme.css.map, line 0)

Edit 2: I removed all bootstrap files from application directory and just imported gems-- now there is no error in the console at all. Just a few warnings about unexpected CSS tokens (which is just a browser compatability thing: https://www.quora.com/Why-does-Safari-display-three-warnings-in-Bootstrap) but the signup button still doesn't do anything.

Community
  • 1
  • 1
segue_segway
  • 1,490
  • 1
  • 22
  • 40

1 Answers1

0

Nevermind-- was never an issue with JS caching. I wasn't yielding correctly in my application.html.erb-- the comments I put in my application layout were continuing into my form element. I noticed this when I checked my page source and saw that the html tag was commented out. Thanks for the help all!

segue_segway
  • 1,490
  • 1
  • 22
  • 40