2017-01-21 2 views
0

나는 Heroku와 레일을 처음 사용합니다. 내 휴대 전화 앱용 API를 만드는 기사를 읽었습니다.Heroku 코드 = H10 응용 프로그램이 손상됨

내가 로컬 만들기에 성공하고 난 서버를 실행할 때 API를 올바르게 응답,하지만 난 내 응용 프로그램에 Heroku가 링크를 사용하려고 할 때이

at=error code=H10 desc="App crashed" method=GET path="/api/v1/carbrands/" host=b-taxi-server.herokuapp.com request_id=283223f5-f68d-4c4a-bb70-3346a2e3327f fwd="156.205.91.128" dyno= connect= service= status=503 bytes= 

at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=b-taxi-server.herokuapp.com request_id=10510255-6149-4583-8886-6bbb69f37aaa fwd="156.205.91.128" dyno= connect= service= status=503 bytes= 

/app/app/controllers/Api/V1/carbrands_controller.rb:1:in `<top (required)>': uninitialized constant Api (NameError) 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:472:in `block (2 levels) in eager_load!' 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:471:in `each' 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:471:in `block in eager_load!' 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:469:in `each' 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:469:in `eager_load!' 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/engine.rb:346:in `eager_load!' 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/application/finisher.rb:56:in `each' 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>' 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `instance_exec' 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `run' 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:55:in `block in run_initializers' 
     from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each' 
     from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component' 
     from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from' 
     from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component' 
     from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `each' 
     from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `call' 
     from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component' 
     from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each' 
     from /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each' 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/initializable.rb:54:in `run_initializers' 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/application.rb:352:in `initialize!' 
     from /app/config/environment.rb:5:in `<top (required)>' 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/application.rb:328:in `require_environment!' 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:142:in `require_application_and_environment!' 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:67:in `console' 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!' 
     from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>' 
     from bin/rails:4:in `require' 
     from bin/rails:4:in `<main>' 

Carbrands 컨트롤러를 말하는 로그 \ 콘솔에서 오류가 $$ \ 응용 프로그램의 \ 컨트롤러 아래 \ API 광고 \ V1 \ carbrands_controller.rb

I했습니다 내 경로에

class Api::V1::CarbrandsController < ApplicationController 
    respond_to :json 
    skip_before_filter :verify_authenticity_token 

    def index 
     output_brands 
    end 

    def output_brands 
     brands = CarBrand.all 
     #@trips = Trip.all 
     if brands 
     respond_to do |format| 
     format.html 
     format.json { render :json => brands.to_json, status: status } #see if you want to send the cars for each user or not 
     end 
     else 
     output_error(401, @noBrands_found) 
     end  

    end 

end 

을 다음 한 컨트롤러 carbrands_controller.rb I 있다

Rails.application.routes.draw do 
    #api routes path 
    #devise_for :users 
    namespace :api, defaults: { format: :json } do 
    namespace :v1 do 
     resources :carbrands, only: [:create, :index] 
    end 
    end 
end 

정직하지 못한 것이 무엇인지 잘 모릅니다. 코드를 밀어 넣었습니다 git push heroku master

어떻게 해결합니까?

답변

0

마지막으로 해결책을 찾았습니다.

컨트롤러는 app \ controllers \ Api \ V1 \에 있습니다. 그러므로 "A"와 "V"는 자본이었다. 폴더의 이름을 "a"와 "v"로 바꿔야했습니다. 그 때 그것은 일했다! !!

또한 때로는 git이 이러한 변경 사항을 인식하지 않도록 전체 폴더 "Api"를 삭제하는 것입니다. >> 커밋 >>> "api"로 다시 작성한 다음 커밋하십시오. 그 후 나는 밀었고 영웅은 일했다

관련 문제