2015-06-11 2 views
0

На моей локальной машине я могу добавить нового пользователя через форму и отправить рельсы ему электронное письмо. Но на heroku все работает до тех пор, пока пользователь не представит форму, и я ожидаю увидеть что-то вроде страницы приветствия. Это страницы, на которые он перенаправлен после регистрации.Шаблон рендеринга не будет работать на 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 создается, я сделать шаблон. Этот шаблон отлично отображается на локальном хосте, но не на героку.

Я пробовал heroku pg:reset, но не могу найти, как его исправить. Это мои журналы с героем.

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]l.com 
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.3+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 
+0

У меня были проблемы с Heroku и прекомпиляцией активов, если это так [https://devcenter.heroku.com/articles/rails-4-asset-pipeline] может оказаться полезным –

+0

«Этот шаблон показывает отлично на localhost, но не на героку .... "не описательно. Что вы видите на герою после того, как пользователь отправляет форму: пустая страница, ошибка сервера 500, что-то еще? – Elvn

ответ

2

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 ... Я бы проверить конфигурацию, что и обеспечить который посылает мои первые шаги.

1

Попробуйте удалить главную косую черту из раздела "/ static_pages/welcome". Heroku может блокировать это как потенциальный эксплойт безопасности.

+0

это не исправляет это в моем случае. – Emanuel

+0

Мне любопытно, почему вы не видите более подробное сообщение об ошибке от Heroku. У вас установлен камень 12factor? –

+0

У меня не было этого драгоценного камня. просто установил его. совершенные и подталкиваемые к герою, та же ошибка, одни и те же журналы. Я также немного удивлен, почему журналы heroku не дают никакой полезной информации, в таких случаях я понятия не имею, что делать. – Emanuel

Смежные вопросы