Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Heroku Rails应用程序不允许通过Desive登录/注销_Ruby On Rails_Ruby_Ruby On Rails 4_Heroku_Devise - Fatal编程技术网

Ruby on rails Heroku Rails应用程序不允许通过Desive登录/注销

Ruby on rails Heroku Rails应用程序不允许通过Desive登录/注销,ruby-on-rails,ruby,ruby-on-rails-4,heroku,devise,Ruby On Rails,Ruby,Ruby On Rails 4,Heroku,Devise,我当前的项目似乎在登录/注销方面有问题,但在生产中只返回500个错误。当我在开发中在本地运行它时,一切都很顺利。页面出现,只有在我成功输入登录信息或尝试注销时才会发生错误。我已经阅读了代码,查看了heroku日志等,但我无法解决这个问题。有些事情让我觉得这是由于我在环境/开发和生产文件中的邮件,但也许不是 我已经检查了一整天,无法解决这个问题。它昨天运行得非常好,我还要补充一点,我已经尝试迁移到heroku,但仍然没有结果。这只是返回:ActiveRecord::SchemaMigration

我当前的项目似乎在登录/注销方面有问题,但在生产中只返回500个错误。当我在开发中在本地运行它时,一切都很顺利。页面出现,只有在我成功输入登录信息或尝试注销时才会发生错误。我已经阅读了代码,查看了heroku日志等,但我无法解决这个问题。有些事情让我觉得这是由于我在环境/开发和生产文件中的邮件,但也许不是

我已经检查了一整天,无法解决这个问题。它昨天运行得非常好,我还要补充一点,我已经尝试迁移到heroku,但仍然没有结果。这只是返回:ActiveRecord::SchemaMigration Load 2.8ms从schema_迁移中选择schema_迁移。*。这就是我的文件的外观:

环境/发展:

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

# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false

# Do not eager load code on boot.
config.eager_load = false

# Show full error reports and disable caching.
config.consider_all_requests_local       = true
config.action_controller.perform_caching = false

# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = true

# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log

# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load

# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true

# 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

# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true

# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true

config.action_mailer.default_url_options = { :host => 'localhost:3000' }

end
环境/生产:

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.default_url_options = { :host => 'programinperson.com' }

end
这似乎是heroku日志返回的结果:

2015-07-03T21:43:20.852266+00:00 heroku[router]: at=info method=GET path="/assets/application-c650ec08eab8760c43c795f72c49b7876951ab1ba6a11806a2ce7a63fbf31209.js" host=www.programinperson.com request_id=d3e04089-0dff-4f53-a8d6-eaf8b4808240 fwd="98.160.140.78" dyno=web.1 connect=2ms service=6ms status=304 bytes=133
2015-07-03T21:43:22.284984+00:00 app[web.1]:    (0.5ms)  BEGIN
2015-07-03T21:43:22.286082+00:00 app[web.1]: Completed 500 Internal Server Error in 4ms (ActiveRecord: 1.8ms)
2015-07-03T21:43:22.280157+00:00 app[web.1]: Started DELETE "/users/sign_out" for 98.160.140.78 at 2015-07-03 21:43:22 +0000
2015-07-03T21:43:22.281680+00:00 app[web.1]: Processing by Devise::SessionsController#destroy as HTML
2015-07-03T21:43:22.281686+00:00 app[web.1]:   Parameters: {"authenticity_token"=>"oHbV6VtpWAST1t5oYMJVFaPKyIVSZkP2kIsFYTT/DsYzTErySqJH0ZKIGeKBBCE6WVTxmgW4psPQAuF1nw1IdQ=="}
2015-07-03T21:43:22.283543+00:00 app[web.1]:   User Load (0.7ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1  ORDER BY "users"."id" ASC LIMIT 1  [["id", 1]]
2015-07-03T21:43:22.287538+00:00 app[web.1]: 
2015-07-03T21:43:22.285770+00:00 app[web.1]:    (0.6ms)  ROLLBACK
2015-07-03T21:43:22.287540+00:00 app[web.1]: NoMethodError (undefined method `[]' for nil:NilClass):
2015-07-03T21:43:22.287561+00:00 app[web.1]: 
2015-07-03T21:43:22.287560+00:00 app[web.1]:   app/models/user.rb:9:in `http_protocol'
2015-07-03T21:43:22.287562+00:00 app[web.1]: 
如果您能提供任何信息,我们将不胜感激!我只是被卡住了,不知道从这里该往哪里走。非常感谢你

编辑:这是我的模型在第9行的内容:

before_save :http_protocol

def http_protocol
  unless self.website[/\Ahttp:\/\//] || self.website[/\Ahttps:\/\//]
    self.website = "http://#{self.website}"
  end
end
Joe

保存前过滤器http_协议尝试将用户的网站与regexp匹配:

self.website[/\Ahttp:\/\//]
根据您的日志文件,此操作失败,因为网站为零

为避免该问题,您需要先检查网站是否存在,请将该方法更改为以下方式:

def http_protocol 
  if website.present?
    self.website = "http://#{self.website}" unless website[/\Ahttps?:\/\//]
  end
end

似乎您在app/models/user.rb:9中为nil:NilClass`提供了一个NoMethodError未定义方法[]。你能把你的用户模型贴到第9行吗?我看到了,仔细检查了我的模型,我知道他们在说什么,但我不知道这是个什么问题。我在另一个项目中有这个代码,它在那里工作得很好。非常感谢您提供的任何帮助,谢谢!=:保存之前:http\u协议定义http\u协议除非self.website[/\Ahttp:\/\/\/]\124; self.website[/\Ahttps:\/\/\/]self.website=http://{self.website}end endI不能说我知道什么是网站集?昨天我可以登录/注销,但没有任何问题。上个星期我已经可以登录了,除了一次简单的迁移成功。成功登录。-非常感谢。这完全有道理,我真的非常感谢不幸的是,由于我在这里的经验有限,我无法投票支持你的答案=我给出了答案,再次感谢你=