簡體   English   中英

調試Heroku錯誤日志

[英]Debugging Heroku Error Logs

剛嘗試通過heroku部署我的第一個應用程序。 一切都已連接但由於某種原因,應用程序將不會顯示,保留默認應用程序。 我已經安裝了日志,但是他們跟蹤的錯誤是在我甚至沒有訪問的頁面上(或者知道如何訪問該問題)。 我能夠在此塊中更改的唯一錯誤是應用程序頁面上的語法錯誤

/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `require': /app/config/application.rb:9: class/module name must be CONSTANT (SyntaxError) from /app/vendor/bundle/ruby/2.0.0/gems/railties-
4.2.0/lib/rails/commands/commands_tasks.rb:78:in `block in server' from /app/vendor/bundle/ruby/2.0.0/gems/railties-
4.2.0/lib/rails/commands/commands_tasks.rb:75:in `tap' from 
/app/vendor/bundle/ruby/2.0.0/gems/railties-
4.2.0/lib/rails/commands/commands_tasks.rb:75:in `server' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!' from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in 
`<top (required)>' from bin/rails:8:in `require' from bin/rails:8:in `<main>' 

我的控制器可以在Application Controller下找到

class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception
end

清單控制器

class ListingsController < ApplicationController
  before_action :set_listing, only: [:show, :edit, :update, :destroy]

  # GET /listings
  # GET /listings.json
  def index
    @listings = Listing.all
  end

  # GET /listings/1
  # GET /listings/1.json
  def show
  end

  # GET /listings/new
  def new
    @listing = Listing.new
  end

  # GET /listings/1/edit
  def edit
  end

  # POST /listings
  # POST /listings.json
  def create
    @listing = Listing.new(listing_params)

    respond_to do |format|
      if @listing.save
        format.html { redirect_to @listing, notice: 'Listing was successfully created.' }
        format.json { render :show, status: :created, location: @listing }
      else
        format.html { render :new }
        format.json { render json: @listing.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /listings/1
  # PATCH/PUT /listings/1.json
  def update
    respond_to do |format|
      if @listing.update(listing_params)
        format.html { redirect_to @listing, notice: 'Listing was successfully updated.' }
        format.json { render :show, status: :ok, location: @listing }
      else
        format.html { render :edit }
        format.json { render json: @listing.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /listings/1
  # DELETE /listings/1.json
  def destroy
    @listing.destroy
    respond_to do |format|
      format.html { redirect_to listings_url, notice: 'Listing was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_listing
      @listing = Listing.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def listing_params
      params.require(:listing).permit(:name, :description, :price, :image)
    end
end

application.rb中

require File.expand_path('../boot', __FILE__)

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module etsy_demo
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
    # config.i18n.default_locale = :de

    # Do not swallow errors in after_commit/after_rollback callbacks.
    config.active_record.raise_in_transactional_callbacks = true
  end
end

更新我將其更改回Etsy-Demo后會出現此錯誤

/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `active_record' for #<Rails::Application::Configuration:0x007f8c37d4abf0> (NoMethodError) from /app/config/application.rb:24:in `<class:Application>' from /app/config/application.rb:10:in `<module:EtsyDemo>' from /app/config/application.rb:9:in `<top (required)>' from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `require' from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in `block in server' from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `tap' from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in `server' from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!' from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>' from bin/rails:8:in `require' from bin/rails:8:in `<main>'

新錯誤 /app/config/application.rb:5:in require': cannot load such file -- active_record/railtie (LoadError) from /app/config/application.rb:5:in從/ app / vendor / bundle中的require': cannot load such file -- active_record/railtie (LoadError) from /app/config/application.rb:5:in ' require': cannot load such file -- active_record/railtie (LoadError) from /app/config/application.rb:5:in /ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in require' from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:78:in在服務器的塊中來自/app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb :75:來自/ app / vendor / bundle中的tap' from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in server' /ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in run_command!' from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in run_command!' from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in '來自bin / rails:8:in run_command!' from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in require' from bin/rails:8:in '例外»09:07:51.127

我的問題是由於我的Gemfile沒有組織。 我的應用程序的很多部分只在需要安排時才在開發或整個應用程序中工作。 我在下面附上了我的新Gemfile

source 'https://rubygems.org'

ruby '2.2.0'


gem 'rails', '4.2.0'
# Use sqlite3 as the database for Active Record

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'bootstrap-sass', '~> 3.1.1.0'
gem "paperclip", "~> 4.2"

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc


# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
  gem 'sqlite3'
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end


group :production do
  gem 'pg'
  gem 'rails_12factor'
end

我認為問題是你的一個控制器/模型有一個沒有正確大寫的類名。

去檢查您的模型/控制器是否具有正確的大小寫,例如

class YourController < ApplicationController
end

代替

class yourcontroller < ApplicationController
end

然后重新部署。

更新:

嘗試將config/Application.rb module etsy_demo更改為:

module EtsyDemo

更新號碼 2:

添加到config/Application.rb

require 'rails/all'
require "active_record/railtie"

或者注釋掉:

config.active_record.raise_in_transactional_callbacks = true

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM