我花了几个小时试图为我的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