2017-01-21 19 views
0

ヘロクとレールが初めてです。私は私の電話アプリの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コントローラ言っログ\コンソールでエラーが出ます$$ \アプリの\コントローラの下にある\アピ\ 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 have

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

私は最終的に私のための解決策を見つけました。

コントローラは、\ controllers \ Api \ V1 \の下にありました。したがって、「A」と「V」は資本であった。私はフォルダの名前を "a"と "v"にする必要がありました。その後、それは働いた!!

また、gitはこれらの変更を気付かないので、私がしたことはフォルダ "Api" >>をコミットすることです>>>それを "api"で再作成してコミットしてください。その後、私は押して、英雄は働いた

関連する問題