我正在使用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)
的Gemfile
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
application.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
非常感谢任何帮助或想法!
答案 0 :(得分:0)
您需要将class ProjectsController < ActionController::Base
更改为class ProjectsController < ApplicationController
,然后才会知道在哪里搜索布局。