简体   繁体   English

Rails / Heroku中的生产环境如何工作?

[英]How does the production environment in Rails / Heroku work?

I'm trying to learn Rails by making a blog for myself and deploying it on Heroku, but I'm encountering a NoMethodError on a custom gem. 我试图通过为自己创建一个博客并将其部署在Heroku上来学习Rails,但是在自定义gem上遇到了NoMethodError。 Everything is working locally in Development, but I keep encountering errors when moving to Production. 一切都在开发环境中本地进行,但是在转入生产环境时,我总是遇到错误。

Processing by HomeController#index as HTML
2012-08-18T02:17:11+00:00 app[web.1]:   Rendered home/index.html.erb within layouts/application (4.1ms)
2012-08-18T02:17:11+00:00 app[web.1]: Completed 500 Internal Server Error in 19ms
2012-08-18T02:17:11+00:00 app[web.1]: 
2012-08-18T02:17:11+00:00 app[web.1]: ActionView::Template::Error (undefined method `bbcode_to_html' for #<String:0x000000032ee278>):
2012-08-18T02:17:11+00:00 app[web.1]:     3:    <p class="article_body"><%= raw Post.last.body.bbcode_to_html %></p>
2012-08-18T02:17:11+00:00 app[web.1]:     1: <div id="homepage_headline">
2012-08-18T02:17:11+00:00 app[web.1]:     4: </div>
2012-08-18T02:17:11+00:00 app[web.1]: 
2012-08-18T02:17:11+00:00 app[web.1]:     2:    <h1 class="article_title_headlines"><%= link_to "#{Post.last.title}", post_path(Post.last) %></h1>
2012-08-18T02:17:11+00:00 app[web.1]: 
2012-08-18T02:17:11+00:00 app[web.1]:   app/views/home/index.html.erb:3:in `_app_views_home_index_html_erb__3063155323426577095_38919220'

I've included bb-ruby in my Gemfile like so: 我将bb-ruby包含在我的Gemfile中,如下所示:

group :production do
    gem 'thin'
    gem 'pg'
    gem 'bb-ruby', '0.9.6', :path => 'vendor/bb-ruby'
end
...
gem 'bb-ruby', '0.9.6', :path => 'vendor/bb-ruby'

I've tried requiring bb-ruby in the view, but then Heroku gave me a file not found error. 我尝试过在视图中要求bb-ruby,但是Heroku给了我一个文件未找到错误。

I guess my main question is this: what's the difference between production on Heroku and development on my machine? 我想我的主要问题是:Heroku的生产和我的机器的开发有什么区别? Other than what I can tell from the evironments' config files. 除了我可以从环境的配置文件中看出来的以外。 All I know so far is that Heroku requires assets like javascript and css to be precompiled. 到目前为止,我所知道的是Heroku要求对javascript和CSS之类的资产进行预编译。 But what about gems? 但是宝石呢? I haven't been able to find a very good explanation about how to use custom gems in Heroku. 对于如何在Heroku中使用自定义宝石,我一直找不到很好的解释。 I appreciate any help. 感谢您的帮助。

UPDATE: I've been able to get the app to work properly by using version 0.9.5 of bb-ruby. 更新:通过使用bb-ruby的0.9.5版,我已经能够使应用程序正常运行。 Version 0.9.6 was a version I created myself (working in development) but is causing problems in Heroku, I think because I packaged it myself and specified the path. 0.9.6版本是我创建的自己的版本(正在开发中),但是在Heroku中引起了问题,我想是因为我自己打包并指定了路径。

Don't specify path, Heroku overrides this and the default is fine unless you know better. 不要指定路径,Heroku会覆盖它,并且默认值是可以的,除非您更了解。 You also want pg and bb-ruby without a specific group since you need it everywhere. 您还需要没有特定组的pg和bb-ruby,因为您到处都需要它。

为了使用您自己的自定义版本,请在github中存储gem,进行自己的更改,然后在gemfile中使用:git选项指向它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM