0

我正在使用 ZURB Foundation 创建一个新应用程序。共有三个控制器。其中之一 - 一切正常,当我在开发中运行服务器时,所有 css 和 javascripts 都包括在内。但是如果我运行我的 Projects#Controller,它只会得到纯 html,而不加载 javascripts 和 css。我尝试了一切,但仍然不知道如何处理它。

这是来自控制台的日志:

当它工作正常时

Started GET "/" for 127.0.0.1 at 2013-01-09 21:36:21 +0200
Processing by PagesController#info as HTML
  Rendered pages/info.html.erb within layouts/application (0.3ms)
  Rendered layouts/_head.html.erb (36.9ms)
  User Load (1.6ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
  Rendered layouts/_header.html.erb (8.9ms)
  Rendered layouts/_flash_messages.html.erb (0.3ms)
  Rendered layouts/_footer.html.erb (66.0ms)
Completed 200 OK in 368ms (Views: 365.2ms | ActiveRecord: 1.6ms)

但是,如果我从另一个控制器转到另一个页面,它只会从页面加载纯 html

Started GET "/projects/" for 127.0.0.1 at 2013-01-09 21:23:21 +0200
Processing by ProjectsController#index as HTML
  User Load (1.1ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
  Project Load (0.5ms)  SELECT "projects".* FROM "projects" WHERE "projects"."user_id" = 1 ORDER BY created_at desc
  Rendered projects/index.html.erb (30.8ms)
Completed 200 OK in 78ms (Views: 38.4ms | ActiveRecord: 2.7ms)

宝石文件

    source 'https://rubygems.org'

gem 'rails', '3.2.11'

group :development, :test do
  gem 'sqlite3'
  gem 'rspec-rails'
  gem 'factory_girl_rails'
end

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  gem 'compass-rails'
  gem 'zurb-foundation'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'
gem 'devise'
gem 'thin'
gem 'best_in_place'

group :test do
  gem 'capybara'
  gem 'shoulda-matchers'
end

group :production do
  gem 'pg'
end

应用程序.html.erb

<!DOCTYPE html>
<html lang="en">
  <head>
    <%= render 'layouts/head' %>
  </head>
  <body>
    <%= render 'layouts/header' %>
    <div class="container-fluid">
      <div class="row-fluid">
        <div class="span8 offset2">
          <%= render 'layouts/flash_messages' %>
          <%= yield %>
        </div>
      </div>
    </div>
    <div class='row-fluid'>
      <%= render 'layouts/footer' %>
    </div>
  </body>
</html>

和控制器

class PagesController < ApplicationController
  respond_to :html

  def info

  end
end


class ProjectsController < ActionController::Base
  # before_filter :authenticate_user!

  def index
    @projects = current_user.projects

    respond_to do |format|
      format.html
    end

  end
end

任何帮助或想法将不胜感激!

4

1 回答 1

0

您需要更改class ProjectsController < ActionController::Baseclass ProjectsController < ApplicationController,然后它将知道在哪里搜索布局。

于 2013-01-09T19:53:32.950 回答