我已经安装了bootstrap-sass gem,我发现css在某些页面上工作而不是其他页面,我不知道为什么会这样。我已经包含了它不起作用的视图,Gemfile和样式表。
的Gemfile: - 来源'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'pg', '~> 0.15.1'
gem "bcrypt-ruby", '~> 3.0.1'
gem "paperclip", '~> 3.4.2'
gem "will_paginate", '~> 3.0.4'
gem "friendly_id", '~> 4.0.9'
gem 'stripe'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'bootstrap-sass', '~> 2.3.2'
end
group :test do
gem 'rspec-rails', '2.13.2'
gem 'factory_girl_rails', '~> 4.2.1'
gem 'capybara', '~> 2.1'
gem 'launchy', '~> 2.3'
gem 'guard-rspec', '~> 3.0.1'
gem 'shoulda-matchers', '~> 2.1'
gem 'webmock'
end
group :development do
gem 'annotate', ">=2.5.0"
end
group :test, :development do
gem 'database_cleaner'
gem 'rspec-rails', '2.13.2'
gem 'guard-rspec', '~> 3.0.1'
gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
gem 'fuubar', '~> 1.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails', '~> 3.0.1'
application.css.scss: -
*= require_self
*= require_tree .
*/
@import "bootstrap";
baskets.html.erb
<p><%= notice %></p>
<p><%= @basket_items.product_totals %><p>
<%= button_to "Purchase products", new_payment_path, :class => "btn" %>
<table class="table table-hover">
<tr>
<th>Picture</th>
<th>Name</th>
<th>Price</th>
<th></th>
</tr>
<tr>
<% @basket_items.each do |item| %>
<td><p>Nothingness</p></td>
<td><p><%= item.product.name %></p></td>
<td><p><%= item.product.price %></p></td>
<td><%= button_to 'Remove', basket_item_path(item.id), :method => 'delete', :confirm => 'Are you sure?', :class => "btn" %></td>
<% end %>
</tr>
</table>
类别显示 show.html.erb
<button type="button" class="close" data-dismiss="alert">×</button>
<p><%= flash[:notice] %></p>
<div class="search">
<%= form_tag(search_path, method: "get", :class => "form-search") do %>
<%= text_field_tag(:query, nil, :class => "input-medium search-query") %>
<%= submit_tag("Search", :class => "btn") %>
<% end %>
</div>
<div class="container-fluid">
<div class="row-fluid">
<% @cp.each do |p| %>
<div class="product">
<div class="product-image">
<%= image_tag p.image %>
</div>
<p><%= p.price %></p>
<p><%= link_to p.name, product_path(p.slug) %></p>
<% end %>
</div>
</div>
</div>
categories.css.scss
.product {
display: inline-block;
}
.product-image {
width: 40px;
height: 50px;
}
.row-fluid {
margin-top: 300px;
}
.search {
margin: 100px 10px 0px 0px;
}
答案 0 :(得分:1)
如果您可能比“不工作”更具体,这将有所帮助,但通常如果资产未正确加载或资产的旧版本显示,您很可能忘记预编译资产。
尝试运行bundle exec rake assets:precompile
,然后重新加载页面。
答案 1 :(得分:0)
我有类似的问题。对我来说,这是因为我的供应商目录中有一个资产文件夹,并且在那个样式表文件夹中。我假设rails检查了这些文件夹的bootstrap,因为它们存在而不是导入bootstrap gem?一旦我删除它,它就完美无缺。