渲染模板在heroku上不起作用,但在本地可用

艾米

在我的本地计算机上,我可以通过表单添加新用户,并让Rails向他发送电子邮件。但是在heroku上,一切正常,直到用户提交表单为止,我希望看到类似“欢迎”页面的内容。那是他注册后重定向到的页面。

production.rb

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # Code is not reloaded between requests.
  config.cache_classes = true

  # Eager load code on boot. This eager loads most of Rails and
  # your application in memory, allowing both threaded web servers
  # and those relying on copy on write to perform better.
  # Rake tasks automatically ignore this option for performance.
  config.eager_load = true

  # Full error reports are disabled and caching is turned on.
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  # Enable Rack::Cache to put a simple HTTP cache in front of your application
  # Add `rack-cache` to your Gemfile before enabling this.
  # For large-scale production use, consider using a caching reverse proxy like
  # NGINX, varnish or squid.
  # config.action_dispatch.rack_cache = true

  # Disable serving static files from the `/public` folder by default since
  # Apache or NGINX already handles this.
  config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?

  # Compress JavaScripts and CSS.
  config.assets.js_compressor = :uglifier
  # config.assets.css_compressor = :sass

  # Do not fallback to assets pipeline if a precompiled asset is missed.
  config.assets.compile = false

  # Asset digests allow you to set far-future HTTP expiration dates on all assets,
  # yet still be able to expire them through the digest params.
  config.assets.digest = true

  # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb

  # Specifies the header that your server uses for sending files.
  # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX

  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
  # config.force_ssl = true

  # Use the lowest log level to ensure availability of diagnostic information
  # when problems arise.
  config.log_level = :debug

  # Prepend all log lines with the following tags.
  # config.log_tags = [ :subdomain, :uuid ]

  # Use a different logger for distributed setups.
  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)

  # Use a different cache store in production.
  # config.cache_store = :mem_cache_store

  # Enable serving of images, stylesheets, and JavaScripts from an asset server.
  # config.action_controller.asset_host = 'http://assets.example.com'

  # Ignore bad email addresses and do not raise email delivery errors.
  # Set this to true and configure the email server for immediate delivery to raise delivery errors.
  # config.action_mailer.raise_delivery_errors = false

  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation cannot be found).
  config.i18n.fallbacks = true

  # Send deprecation notices to registered listeners.
  config.active_support.deprecation = :notify

  # Use default logging formatter so that PID and timestamp are not suppressed.
  config.log_formatter = ::Logger::Formatter.new

  # Do not dump schema after migrations.
  config.active_record.dump_schema_after_migration = false

  config.action_mailer.delivery_method = :smtp
  # SMTP settings for gmail
  config.action_mailer.smtp_settings = {
   :address              => "smtp.gmail.com",
   :port                 => 587,
   :user_name            => ENV['[email protected]'],
   :password             => ENV['mypassword'],
   :authentication       => "plain",
   :enable_starttls_auto => true }
end

investors_controller.rb

class InvestorsController < ApplicationController
  def index
    #change from Investor.first!!!
    @investor = Investor.first
  end

  def show
    @investor = Investor.find(params[:id])
  end

  def new
    @investor = Investor.new
  end

  def create
    @investor = Investor.new(user_params)
    if @investor.save
        flash[:info] = "Welcome, you're now on your way to success!"
        render "/static_pages/welcome"
      InvestorMailer.welcome_email(@investor).deliver_now
    else
        render 'new'
    end
  end

  def update
    if @investor.update_attributes(user_params)
        flash[:success] = "Updated"
    else
        render 'edit'
    end
  end

  private

    def user_params
      params.require(:investor).permit(:name, :email, :country,
                                   :phone)
    end
end

Investor创建完后,从控制器中渲染一个模板。该模板在localhost上显示正常,但在heroku上显示不正常。

我已经尝试过,heroku pg:reset但似乎找不到解决方法。这是我的Heroku日志。

2015-06-11T11:47:21.908239+00:00 heroku[api]: Enable Logplex by [email protected]
2015-06-11T11:47:21.908239+00:00 heroku[api]: Release v2 created by [email protected]
2015-06-11T11:51:22.979153+00:00 heroku[api]: Set LANG, RAILS_ENV, RACK_ENV, SECRET_KEY_BASE, RAILS_SERVE_STATIC_FILES config vars by [email protected]
2015-06-11T11:51:22.979153+00:00 heroku[api]: Release v3 created by [email protected]
2015-06-11T11:51:23.395722+00:00 heroku[api]: Attach DATABASE resource by [email protected]
2015-06-11T11:51:23.395722+00:00 heroku[api]: Release v4 created by [email protected]
2015-06-11T11:51:23.621173+00:00 heroku[api]: Scale to web=1 by [email protected]
2015-06-11T11:51:23.717284+00:00 heroku[slug-compiler]: Slug compilation started
2015-06-11T11:51:23.717304+00:00 heroku[slug-compiler]: Slug compilation finished
2015-06-11T11:51:23.662060+00:00 heroku[api]: Deploy 12cea55 by [email protected]
2015-06-11T11:51:23.662060+00:00 heroku[api]: Release v5 created by [email protected]
2015-06-11T11:51:26.894425+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 29521 -e production`
2015-06-11T11:51:30.475571+00:00 app[web.1]: [2015-06-11 11:51:30] INFO  WEBrick 1.3.1
2015-06-11T11:51:30.475610+00:00 app[web.1]: [2015-06-11 11:51:30] INFO  ruby 2.0.0 (2015-04-13) [x86_64-linux]
2015-06-11T11:51:30.475901+00:00 app[web.1]: [2015-06-11 11:51:30] INFO  WEBrick::HTTPServer#start: pid=3 port=29521
2015-06-11T11:51:31.005422+00:00 heroku[web.1]: State changed from starting to up
2015-06-11T11:56:53.289790+00:00 heroku[router]: at=info method=GET path="/" host=infinite-oasis-2303.herokuapp.com request_id=354682b8-2096-46ab-a299-8d04cbfa92a4 fwd="78.88.252.85" dyno=web.1 connect=1ms service=136ms status=500 bytes=1754
2015-06-11T11:56:53.491368+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=infinite-oasis-2303.herokuapp.com request_id=ded548e3-4670-4f72-8f55-b7b77d334515 fwd="78.88.252.85" dyno=web.1 connect=1ms service=8ms status=200 bytes=228
2015-06-11T11:58:12.228820+00:00 heroku[api]: Starting process with command `bundle exec rake db:create` by [email protected]
2015-06-11T11:58:16.855775+00:00 heroku[run.8863]: Awaiting client
2015-06-11T11:58:16.899503+00:00 heroku[run.8863]: Starting process with command `bundle exec rake db:create`
2015-06-11T11:58:17.195573+00:00 heroku[run.8863]: State changed from starting to up
2015-06-11T11:58:21.732727+00:00 heroku[run.8863]: Process exited with status 0
2015-06-11T11:58:21.744351+00:00 heroku[run.8863]: State changed from up to complete
2015-06-11T12:02:22.580784+00:00 heroku[router]: at=info method=GET path="/" host=infinite-oasis-2303.herokuapp.com request_id=fa00b3d2-92af-45e1-a377-d07682730c57 fwd="78.88.252.85" dyno=web.1 connect=1ms service=13ms status=500 bytes=1754
2015-06-11T12:02:33.888628+00:00 heroku[api]: Starting process with command `bundle exec rake db:migrate` by [email protected]
2015-06-11T12:02:37.574303+00:00 heroku[run.8055]: Awaiting client
2015-06-11T12:02:37.632103+00:00 heroku[run.8055]: Starting process with command `bundle exec rake db:migrate`
2015-06-11T12:02:37.950399+00:00 heroku[run.8055]: State changed from starting to up
2015-06-11T12:02:42.809261+00:00 heroku[run.8055]: State changed from up to complete
2015-06-11T12:02:42.795864+00:00 heroku[run.8055]: Process exited with status 0
2015-06-11T12:02:48.465779+00:00 heroku[router]: at=info method=GET path="/" host=infinite-oasis-2303.herokuapp.com request_id=b335d5c3-6057-4f55-83ff-7852c60043eb fwd="78.88.252.85" dyno=web.1 connect=2ms service=26ms status=200 bytes=1506
2015-06-11T12:02:48.665596+00:00 heroku[router]: at=info method=GET path="/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css" host=infinite-oasis-2303.herokuapp.com request_id=3850955a-f544-462c-bb56-659cf2a37004 fwd="78.88.252.85" dyno=web.1 connect=3ms service=5ms status=200 bytes=212
2015-06-11T12:02:49.142636+00:00 heroku[router]: at=info method=GET path="/assets/application-b598aa7e82e5647cd54ae6f409306995766dd0ce1af586bab9ebe84804d0eec0.js" host=infinite-oasis-2303.herokuapp.com request_id=aaa58ef4-4c05-467b-aeed-0c61755fc492 fwd="78.88.252.85" dyno=web.1 connect=1ms service=201ms status=200 bytes=117764
2015-06-11T12:03:04.152723+00:00 heroku[router]: at=info method=GET path="/investors/new" host=infinite-oasis-2303.herokuapp.com request_id=2573afdc-9a0a-4aab-a4ca-83215653cb4f fwd="78.88.252.85" dyno=web.1 connect=1ms service=32ms status=200 bytes=2207
2015-06-11T12:03:14.390979+00:00 heroku[router]: at=info method=POST path="/investors" host=infinite-oasis-2303.herokuapp.com request_id=1a95c9bc-ea25-4a75-bc51-ef385a06c765 fwd="78.88.252.85" dyno=web.1 connect=1ms service=567ms status=500 bytes=1754
2015-06-11T12:04:46.584140+00:00 heroku[router]: at=info method=POST path="/investors" host=infinite-oasis-2303.herokuapp.com request_id=661e547b-f2b9-459b-a15c-e4aca2a3fa16 fwd="78.88.252.85" dyno=web.1 connect=5ms service=322ms status=500 bytes=1754
2015-06-11T12:04:52.175142+00:00 heroku[router]: at=info method=GET path="/" host=infinite-oasis-2303.herokuapp.com request_id=9c97165a-fad1-453c-9902-2ea72a63f393 fwd="78.88.252.85" dyno=web.1 connect=1ms service=14ms status=200 bytes=1506
2015-06-11T12:04:52.349183+00:00 heroku[router]: at=info method=GET path="/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css" host=infinite-oasis-2303.herokuapp.com request_id=d1d85822-b7d2-49f6-b4a7-aab4640f9efc fwd="78.88.252.85" dyno=web.1 connect=1ms service=4ms status=304 bytes=133
2015-06-11T12:04:52.636697+00:00 heroku[router]: at=info method=GET path="/assets/application-b598aa7e82e5647cd54ae6f409306995766dd0ce1af586bab9ebe84804d0eec0.js" host=infinite-oasis-2303.herokuapp.com request_id=f12ec67a-29c2-494a-90c8-2fced158045b fwd="78.88.252.85" dyno=web.1 connect=1ms service=4ms status=304 bytes=133
2015-06-11T12:04:57.447980+00:00 heroku[router]: at=info method=GET path="/investors/new" host=infinite-oasis-2303.herokuapp.com request_id=8300be1c-136c-4595-aaa3-fcbec763358f fwd="78.88.252.85" dyno=web.1 connect=2ms service=12ms status=200 bytes=2207
2015-06-11T12:05:10.874873+00:00 heroku[router]: at=info method=POST path="/investors" host=infinite-oasis-2303.herokuapp.com request_id=5d322cae-1009-4a4a-b586-acbc1a1bb0be fwd="78.88.252.85" dyno=web.1 connect=2ms service=308ms status=500 bytes=1754
2015-06-11T12:07:25.348309+00:00 heroku[router]: at=info method=GET path="/" host=infinite-oasis-2303.herokuapp.com request_id=f45225d8-d1d9-4c2a-95e6-bbdb589ee80b fwd="78.88.252.85" dyno=web.1 connect=0ms service=13ms status=200 bytes=1506
2015-06-11T12:07:25.516873+00:00 heroku[router]: at=info method=GET path="/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css" host=infinite-oasis-2303.herokuapp.com request_id=8995aed0-688e-4f4f-87cb-fb32dd61bfb0 fwd="78.88.252.85" dyno=web.1 connect=1ms service=3ms status=304 bytes=133
2015-06-11T12:07:25.803024+00:00 heroku[router]: at=info method=GET path="/assets/application-b598aa7e82e5647cd54ae6f409306995766dd0ce1af586bab9ebe84804d0eec0.js" host=infinite-oasis-2303.herokuapp.com request_id=2b6eefdf-6e08-40cd-bbdc-9eddbb00b375 fwd="78.88.252.85" dyno=web.1 connect=1ms service=6ms status=304 bytes=133
2015-06-11T12:07:56.107177+00:00 heroku[router]: at=info method=GET path="/investors/new" host=infinite-oasis-2303.herokuapp.com request_id=f3ff502c-1a21-43bd-95ec-0557b63f83bc fwd="78.88.252.85" dyno=web.1 connect=0ms service=11ms status=200 bytes=2207
2015-06-11T12:08:04.826779+00:00 heroku[router]: at=info method=POST path="/investors" host=infinite-oasis-2303.herokuapp.com request_id=75971fd1-c059-4185-95e2-5d4e7a769366 fwd="78.88.252.85" dyno=web.1 connect=3ms service=314ms status=500 bytes=1754
光盘

到/ investors / new的POST引发500错误:

2015-06-11T12:05:10.874873+00:00 heroku[router]: at=info method=POST path="/investors" host=infinite-oasis-2303.herokuapp.com request_id=5d322cae-1009-4a4a-b586-acbc1a1bb0be fwd="78.88.252.85" dyno=web.1 connect=2ms service=308ms status=500 bytes=1754

我的猜测是这与InvestorMailer有关...我将检查配置,并确保将其作为第一步发送。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Django模板添加和比较在Heroku上不起作用

来自分类Dev

Javascript在Heroku中不起作用,但在本地环境中起作用

来自分类Dev

html页面在本地时有效,但在云ide上不起作用

来自分类Dev

Fancybox在现场站点上不起作用,但在本地工作

来自分类Dev

jQuery在Drupal平台上不起作用,但在本地运行良好

来自分类Dev

PHP Captcha 在服务器上不起作用,但在本地工作

来自分类Dev

Javascript 代码在本地工作但在实时站点上不起作用

来自分类Dev

Eslint在本地系统上不起作用

来自分类Dev

Eslint在本地系统上不起作用

来自分类Dev

回形针-ffmpeg在Heroku上不起作用

来自分类Dev

图像Magick在Heroku上不起作用

来自分类Dev

Bootstrap在Heroku上不起作用

来自分类Dev

Django Session在Heroku上不起作用

来自分类Dev

Fancy Box在Heroku上不起作用

来自分类Dev

Coffeescript在heroku上不起作用

来自分类Dev

搜索查询在Heroku上不起作用

来自分类Dev

标头位置在服务器上不起作用,但在本地主机上起作用

来自分类Dev

CSS背景图像在SP 2013中不起作用,但在本地可用

来自分类Dev

Django管理模板覆盖'change_list'在Heroku上不起作用

来自分类Dev

cURL请求在服务器上工作正常,但在我的本地主机上不起作用:8080

来自分类Dev

在WAMP本地主机上有效但在WebServer上不起作用的PHP代码

来自分类Dev

cURL请求在服务器上工作正常,但在我的本地主机上不起作用:8080

来自分类Dev

Laravel 导出在服务器上不起作用,但在本地主机上运行良好

来自分类Dev

可用的chromedriver在64位Mac上不起作用

来自分类Dev

Ajax渲染在SelectBooleanCheckbox上不起作用

来自分类Dev

错误:onSubmit在reactjs jsx渲染方法上不起作用

来自分类Dev

.htaccess在本地主机上不起作用

来自分类Dev

本地主机在优胜美地上不起作用

来自分类Dev

Swift WKWebView加载本地文件在设备上不起作用

Related 相关文章

  1. 1

    Django模板添加和比较在Heroku上不起作用

  2. 2

    Javascript在Heroku中不起作用,但在本地环境中起作用

  3. 3

    html页面在本地时有效,但在云ide上不起作用

  4. 4

    Fancybox在现场站点上不起作用,但在本地工作

  5. 5

    jQuery在Drupal平台上不起作用,但在本地运行良好

  6. 6

    PHP Captcha 在服务器上不起作用,但在本地工作

  7. 7

    Javascript 代码在本地工作但在实时站点上不起作用

  8. 8

    Eslint在本地系统上不起作用

  9. 9

    Eslint在本地系统上不起作用

  10. 10

    回形针-ffmpeg在Heroku上不起作用

  11. 11

    图像Magick在Heroku上不起作用

  12. 12

    Bootstrap在Heroku上不起作用

  13. 13

    Django Session在Heroku上不起作用

  14. 14

    Fancy Box在Heroku上不起作用

  15. 15

    Coffeescript在heroku上不起作用

  16. 16

    搜索查询在Heroku上不起作用

  17. 17

    标头位置在服务器上不起作用,但在本地主机上起作用

  18. 18

    CSS背景图像在SP 2013中不起作用,但在本地可用

  19. 19

    Django管理模板覆盖'change_list'在Heroku上不起作用

  20. 20

    cURL请求在服务器上工作正常,但在我的本地主机上不起作用:8080

  21. 21

    在WAMP本地主机上有效但在WebServer上不起作用的PHP代码

  22. 22

    cURL请求在服务器上工作正常,但在我的本地主机上不起作用:8080

  23. 23

    Laravel 导出在服务器上不起作用,但在本地主机上运行良好

  24. 24

    可用的chromedriver在64位Mac上不起作用

  25. 25

    Ajax渲染在SelectBooleanCheckbox上不起作用

  26. 26

    错误:onSubmit在reactjs jsx渲染方法上不起作用

  27. 27

    .htaccess在本地主机上不起作用

  28. 28

    本地主机在优胜美地上不起作用

  29. 29

    Swift WKWebView加载本地文件在设备上不起作用

热门标签

归档