0

私のレールプロジェクトでを使用しようとしていますが、動作させることができません。私はたいてい、this tutorialに従っています。
これはこれまで私が試したことです。私app/assets/stylesheets/custom.scssブートストラップスイッチレールの宝石が動作しません

@import "bootstrap"; 
@import "bootstrap3-switch"; 
@import "bootstrap-sprockets"; 

/* Rest of the file omitted */ 

の上で私のGemfile

gem 'bootstrap-switch-rails', '~> 3.0.0' 

追加で

を追加しました。この本は、これは私のapplication.js

//= require jquery 
//= require jquery_ujs 
//= require turbolinks 
//= require bootstrap 
//= require bootstrap-switch 
//= require_tree . 

マイapplication.css

です
/* 
* 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 other CSS/SCSS 
* files in this directory. Styles in this file should be added after the last require_* statement. 
* It is generally better to create a new file per style scope. 
* 
*= require_tree . 
*= require_self 
*/ 
*= require bootstrap-switch3 

そして最後に、私はスイッチを使用するフォーム:

<% content_for :head do %> 
    <script type="text/javascript"> 
    $(function() { 
    $("input:checkbox").bootstrapSwitch(); 
    }); 
    </script> 
<% end %> 

<div class="row"> 
    <div class="col-md-6 col-md-offset-3"> 
    <%= form_for(@consultant) do |f| %> 
     <%= render 'consultants/consultant_error_messages' %> 

     <%= f.label :identifier %> 
     <%= f.text_field :identifier, class: 'form-control' %> 

     <%= f.label :email %> 
     <%= f.email_field :email, class: 'form-control' %> 

     <%= f.label :first_name %> 
     <%= f.text_field :first_name, class: 'form-control' %> 

     <%= f.label :last_name %> 
     <%= f.text_field :last_name, class: 'form-control' %> 

     <%= f.label :disabled, "Habilitar/Deshabilitar" %> 
     <%= f.check_box :disabled, :data => { 
     :size=>'small', 'on-color'=>'success', 'on-text'=>'Habilitar', 'off-text'=>'Deshabilitar' 
     } %> 

     <%= f.submit "Guardar", class: "btn btn-primary" %> 
    <% end %> 
    </div> 
</div> 

チェックボックスではなく、スイッチの、定期的なチェックボックスとして表示されています。
私には何が欠けていますか?
ありがとうございます。

+0

別のユーザーがHTMLを書く代わりに、レールによって生成されたものを使用して問題を解決しました – Shrikant1712

+0

ありがとうございますが、動作しませんでした – jmm

答えて

0

も出力を確認するために、コンソールに$("input:checkbox").bootstrapSwitch();を実行してみてください、あなたのapplication.css

require bootstrap3-switchrequire bootstrap-switch3を交換してください。 ** `しよう** custom.scssからそれを削除するだけapplication.cssでbootstrap3-switch`を必要とrails 4 : change state issue with Bootstrap Switch

関連する問題