私は完全に機能する登録フォームを持っていました。スタイルを設定した後(テンプレートのhtml/css/jsをダウンロードしてアプリを配置してページを見やすくする):ブートストラップの統合後にレールが送信されない
1)登録ページが機能しなくなりました。私がsubmitを押すと、何も起こりません。
- 私はこの質問に参照しました:Rails form_for submit button not working私もJavascriptのキャッシングは潜在的に問題があることについて読ん
- (私は私が持っていないと信じて)すべての構文エラーをチェックすると述べました。私が読んだ2つのSOの質問は、bootstrap.jsのe.preventDefault()メソッドについて話しましたが、これらを削除しても私のために何もしませんでした。私が正しいものを削除したかどうか分かりませんか?私は
devise_for :users
を持っている、これは私のユーザー登録ページが新しい、私のルートファイルで
/*! * 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; } }
:ここ
は、私が使用しているテンプレートへの独自のCSSです。 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" %>
このページは上手く表示されていますが、何も起こりません送信ボタンを押すとここで
は私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 .
そして、私の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;
}
}
任意のアイデアですか?
編集はコメントに基づいて情報を含めるには: はrails s
経由で私のローカルサーバーを起動します。
[Error] Failed to load resource: the server responded with a status of 500 (Internal Server Error) (bootstrap-theme.css.map, line 0)
編集2: JavaScriptコンソールは1つのエラーがスローされます私は今ではすべてのコンソールでエラーがないアプリケーションディレクトリからすべてのブートストラップファイルを削除し、ちょうど輸入しますgems--。予期せぬCSSトークン(これは単なるブラウザ互換性のもの:https://www.quora.com/Why-does-Safari-display-three-warnings-in-Bootstrap)に関する警告ですが、サインアップボタンはまだ何もしません。
logs/development.logには何がありますか?ブラウザでデベロッパーツールを開くと、送信時にコンソールにJavascriptエラーが表示されますか? – andrunix
ブラウザのコンソールには何もありませんか?また、どうやってローカルサーバーを起動していますか? –
両方の質問に答えるために編集された質問。皆さんありがとう! – Sunny