English 中文(简体)
Rails环境部署问题?
原标题:Rails environment deployment issue?

我正试图在这里部署我的第一个Rails应用程序,从昨晚开始我就一直在做一些事情。我遇到了一些我无法解释的怪异行为。

我正在运行Rails、Apache、Phusion Passenger,目前还有SQLite 3。(我很快会把它转移到MySQL。)目前,它托管在一个运行Ubuntu Server 11.04(Natty)的太小的EC2切片上。

当我在浏览器中访问EC2切片的地址时,我会收到默认的Rails500通知。但奇怪的是。当我跟踪<code>/log/production.log</code>时,我看到以下错误:

ActionView::Template::Error (SQLite3::SQLException: no such table: offers: SELECT  "offers".* FROM "offers" WHERE (code =   ) ORDER BY created_at desc LIMIT 25 OFFSET 0):

因此,我在SQLite3中手动打开了开发数据库,并在其中看到了该表。但是,生产数据库没有该表。

好的,所以我在生产日志中记录了生产数据库的错误。应用程序必须在生产模式下运行,对吧?

这就是困扰我的地方。首先,它在我的开发机器上以开发模式运行,当我部署它时,我没有更改任何文件。我也没有使用任何花哨的部署工具来部署它(可能在我不知情的情况下切换了一些东西)-我只做了一个简单的<code>git push

此外,我在httdp.conf VirtualHost配置中添加了以下内容:

RailsEnv development

此外,当我运行rails控制台时,我可以得到以下内容:

irb(main):002:0> Rails.env
=> "development"

所以,应用程序真的应该在开发模式下运行,对吧?事实上,它似乎(部分)认为是这样,对吧?

我真的不确定这里发生了什么,我真的很感激一些专家的建议。

谢谢大家。

编辑-几次服务器重新启动后,当我试图在浏览器中查看它时,它就挂起了。此外,当我试图重新启动Apache(因此服务器重新启动)时,它似乎挂起了,是相关的问题,还是完全不同的问题?

最佳回答

嗯,这对我来说不是一个100%满意的答案,但我做了两件事,我想我做到了。

首先,我重新安装了乘客Apache模块。这可能是必要的,也可能不是必要的。

不过,这是一件大事:在我将行添加到httpd.conf以将Rails环境传递给Passenger之后,我认为Apache重新启动错误。(相反,我相信我一辈子都在错误地重新启动Apache!)

我试图以这种方式重新启动Apache:

sudo /etc/init.d/apache2 restart

这一直适用于我(在编程PHP时),但在这里根本不起作用。Apache将在重新启动时停止运行。

但是,这样做效果很好:

sudo apachectl restart

我将不得不问服务器故障,两者之间的显著区别是什么。

我希望这能帮助到别人。

问题回答

暂无回答




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签