我花了幾個小時試圖爲我的rails web應用程序使用引導程序,但它完全沒有做任何事情!我無法爲它調用任何類!Bootstrap在Redmine插件中不起作用
這裏是我的index.html.erb:
<div class="center">
<h1>Welcome to the User Database</h1>
</div>
<div class="jumbotron">
<h2>
This is the home page for the User Database.
</h2>
**<%= link_to "Add new entry", new_user_path, class: "btn btn-primary" %>
<%= button_to "Search", users_search_path, class: "button", :method => :get %>**
</div>
<!-- User Image -->
<div class="center">
<%= image_tag('user.jpg', :plugin => 'users') %>
</div>
<!-- Style sheet -->
<% content_for :header_tags do %>
<%= stylesheet_link_tag 'style', :plugin => 'users' %>
<% end %>
通知粗體代碼...的的link_to線完全忽略引導類,就像它根本不存在!該button_to線工作完全正常...
我的Gemfile包括引導(是的,我跑了包,因爲它的更新安裝):
source 'https://rubygems.org'
if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.5.0')
abort "Redmine requires Bundler 1.5.0 or higher (you're using #{Bundler::VERSION}).\nPlease update with 'gem update bundler'."
end
#Trying to get bootstrap...?
gem 'bootstrap-sass', '3.3.6'
gem "rails", "4.2.3"
gem "jquery-rails", "~> 3.1.3"
...
而且,我的CSS文件肯定包括引導:
@import "bootstrap-sprockets";
@import "bootstrap";
/* mixins, variables, etc. */
/* universal */
body {
padding-top: 0px;
}
section {
overflow: auto;
}
...
我甚至還包括在引導我的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. JavaScript code in this file should be added after the last require_* statement.
//
// 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_tree .
它只是不行!我能想到的唯一的事情就是我正在構建我的Rails應用程序,作爲Redmine插件的一部分,並且這不知怎麼搞亂了所有內容......但我不知道該怎麼做!
UPDATE:
我試着這樣做:
<% content_for :header_tags do %>
<%= stylesheet_link_tag 'application', :plugin => 'users' %>
<% end %>
但我得到這個神祕的錯誤!
ActionController::RoutingError (No route matches [GET] "/plugin_assets/users/stylesheets/bootstrap"):
我不明白這是什麼意思。爲什麼它在樣式表目錄中尋找引導文件?谷歌從來沒有聽說過這個錯誤信息!
首先,不確定':plugin =>'users''試圖做什麼,但刪除它。 其次,你的佈局文件中是否設置了bootstrap的容器div? – phillyslick
我需要該行,因爲我的應用程序是redmine的插件。請參閱:http://www.redmine.org/projects/redmine/wiki/Plugin_Tutorial#Improving-the-plugin-views我沒有任何佈局文件,這就是我所擁有的。我甚至不知道什麼bootstrap的容器div是....?我是一個完全noobie這個東西 – ineedahero
啊,的確。抱歉。你可能不需要容器div。但請查看這裏的文檔:http://getbootstrap.com/css/ 你說'button_to'呈現爲引導按鈕? – phillyslick