Twitter Bootstrap不适用于layout.erb以外的视图

时间:2014-03-17 12:13:05

标签: css twitter-bootstrap sinatra

我正在使用带有.erb模板的Sinatra。当我导航到主页时,Bootstrap工作,这主要是layout.erb。但是当我导航到其他页面时,我看不到Bootstrap效果。有什么想法吗?

这是我的layout.erb文件

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bootstrap 101 Template</title>
    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
    <div class="navbar">
        <div class="navbar-inner">
            <a class="brand" href="#">Title</a>
            <ul class="nav">
                <li class="active"><a href="#">Home</a></li>
                <li><a href="#">Link</a></li>
                <li><a href="#">Link</a></li>
            </ul>
        </div>
    </div>
    <h1>"Flitter"</h1>
    <section>
        <%= yield %>
    </section>
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
  </body>
</html>

奇怪的是,当我访问&#39; / home&#39;时,我可以看到Bootstrap效果。页。这是home.erb:

<p>Welcome to this site that's all about the 
    songs of the great Frank Sinatra. </p>
<img src="/images/sinatra.jpg" alt="frank sinatra">

但我无法看到&#39; / show_user&#39;的效果。这是show_user.erb:

<div>
    <h1> Welcome @<%=@user.name %>. Have fun micro-blogging!</h1>

    <% if @posts != nil %>
        <% @posts.each do |post| %>
            <div>
                <p><%= post.created_at %></p>
                <p><%= post.content %></p>
            </div> 
    <% end %> 
    <% else %>
        <p> no posts created yet </p>
    <%end %>

    <form action="/post" method="POST">
        <div>
            Create new post<br><br>
            <textarea cols="40" rows="5" name="post[content]"></textarea>
        </div>
        <input type="submit" value="Submit">
    </form>
</div>

0 个答案:

没有答案