HAML和ERB渲染问题

时间:2014-04-27 11:31:39

标签: ruby-on-rails apache ubuntu deployment haml

我已经编写了一个RoR应用并尝试部署它。

因此,我的Linode出现以下问题: 浏览器页面只显示我在index.html.haml中编写的代码而不是所谓的页面。 当我尝试使用index.html时,我得到一个有效的渲染页面。 当我尝试使用index.html.erb时,它会部分呈现(某些内容,例如输入,渲染,但有很多字符串的erb代码而且没有css)

同时,我的本地服务器(基于OS X)运行良好,我将基于haml的页面视为正常呈现的html页面。 (我疯了!)

请帮助我了解如何解决这个问题。

Ubuntu 12.04,Apache 2.22,ruby 2.0.0,rails 3.2.12,haml 4.0.5,haml-rails 0.4

提前致谢!

UPD 的Gemfile

source 'https://rubygems.org'

gem 'rails', '3.2.12'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'mysql2'
gem 'devise', '3.0.3'
gem 'debugger'


group :assets do
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
  gem 'therubyracer', :platform => :ruby
end

gem 'less-rails', '~> 2.2.6'
gem 'sass-rails', '~> 3.2.3'
gem 'twitter-bootstrap-rails', '2.2.4'
gem 'friendly_id', '~> 3.2'

gem 'jquery-rails'
gem 'haml', '~> 4.0.0'
gem 'cancan'
gem 'haml-rails'
gem 'rails-i18n', '~> 3.0.0.pre'
gem 'i18n-js'
gem 'obscenity'
gem 'thin'
gem 'will_paginate-bootstrap'
gem 'nifty-generators', :group => :development
gem 'rails_12factor'
gem 'mocha', :group => :test

group :development do
  gem 'sqlite3'
  gem 'capistrano', '2.15.5'
  #gem 'capistrano-rails'
  #gem 'capistrano-bundler'
  #gem 'capistrano-rvm'
  #gem 'rvm1-capistrano3', :require => false
end

gem 'net-ssh', '2.7.0'

gem 'foreman'

Apache配置

<VirtualHost *:80>
  # Admin email, Server Name (domain name), and any aliases
  ServerAdmin admin@mysite.com
  ServerName  www.mysite.com
  ServerAlias mysite.com
  Options Indexes ExecCGI FollowSymLinks
  PassengerResolveSymlinksInDocumentRoot on
  RailsEnv production
  RailsBaseURI /

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php index.html.erb index.html.haml
  DocumentRoot /home/deploy/public/mysite.com/public/app/views/home

  # Log file locations
  LogLevel warn
  ErrorLog  /home/deploy/public/mysite.com/log/error.log
  CustomLog /home/deploy/public/mysite.com/log/access.log combined
</VirtualHost>

1 个答案:

答案 0 :(得分:1)

你应该定义一些关于在thin + apache上运行rails app的手册;这个应该适合你:

http://www.rackspace.com/knowledge_center/article/ubuntu-apache-rails-and-thin

现在你只是使用apache提供静态文件。