【发布时间】:2015-12-13 16:50:07
【问题描述】:
我尝试了多种方法,遵循了许多教程,但我的 Rails 应用程序没有任何效果。这是我的 Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.0.0'
gem 'mysql2'
gem 'paperclip', '~>3.0'
gem 'sass-rails', '~>4.0.0'
gem 'bootstrap-sass', '~>3.2.0.2'
gem 'autoprefixer-rails'
group :doc do
gem 'sdoc', require: false
end
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 vendor/assets/stylesheets of plugins, if any, 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 top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*/
@import "bootstrap-sprockets";
@import "bootstrap";
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 vendor/assets/javascripts of plugins, if any, 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/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require bootstrap-sprockets
//= require jquery_ujs
//= require turbolinks
//= require_tree .
index.html.erb 文件:
<div class="posts index">
<h1>Welcome to The Incognito Social Network</h1>
<%=link_to("Say Something!", {:action=> 'new'}, :class=>'action new')%>
<table class="listing" summary="All posts">
<% @posts.each do |post| %>
<tr><td> </td></tr>
<tr>
<td>Post #<%=post.id%> </td>
<td><%=post.text%></td>
<%if post.image_file_name%>
<td>
<%=image_tag post.image.url %>
</td>
<%end%>
</tr>
<tr>
<td><%= link_to("Like", '#', :class=>'action upvote')%></td>
</tr>
<%end%>
</table>
</div>
我尝试在我的控制器中编写layout false 和#layout false。都没有生效。
rails 应用程序没有任何变化。我尝试将引导代码放在我的 index.html.erb 文件中,但它没有以引导样式出现。它看起来好像是简单的 HTML。有人知道如何解决这个问题吗? 谢谢。
【问题讨论】:
-
您能添加您的
index.html.erb文件吗? -
@Tobias 我已经用 index.html.erb 文件更新了问题
-
您似乎没有为table 应用任何引导类。你试过
<table class="table listing" summary="All posts">吗? -
@vanburen 对我的 Rails 应用程序仍然没有影响。我错过了什么?
-
您检查过该页面是否正在加载 Bootstraps CSS?
标签: css ruby-on-rails twitter-bootstrap ruby-on-rails-4 rubygems