简体   繁体   中英

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. 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:

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.

I guess my main question is this: what's the difference between production on Heroku and development on my machine? 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. But what about gems? I haven't been able to find a very good explanation about how to use custom gems in 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. 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.

Don't specify path, Heroku overrides this and the default is fine unless you know better. You also want pg and bb-ruby without a specific group since you need it everywhere.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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