방금 레일에 루비를 배웁니다. 나는 두 개의 데이터베이스 테이블을 만들었습니다 : 트레이너와 토 키몬. 모든 것이 로컬 호스트 (데이터베이스 포함)에서 제대로 작동하지만 heroku에서 문제가 발생했습니다. 여기 Ruby on rails 앱은 로컬 호스트에서 작동하지만 heroku에서는 작동하지 않습니다.
로그이다 welcome_controller.rb의 일부 여기2016-10-13T21:51:16.840425+00:00 heroku[router]: at=info method=GET path="/" host=a2-tokimon.herokuapp.com request_id=2f86b075-8d64-4616-984a-304df86d9768 fwd="142.58.35.51" dyno=web.1 connect=2ms service=11ms status=500 bytes=1669
2016-10-13T21:51:16.851541+00:00 app[web.1]: Started GET "/" for 142.58.35.51 at 2016-10-13 21:51:16 +0000
2016-10-13T21:51:16.854395+00:00 app[web.1]: Processing by WelcomeController#index as HTML
2016-10-13T21:51:16.858208+00:00 app[web.1]: Rendered welcome/index.erb within layouts/application (3.1ms)
2016-10-13T21:51:16.858340+00:00 app[web.1]: Completed 500 Internal Server Error in 4ms (ActiveRecord: 2.3ms)
2016-10-13T21:51:16.859867+00:00 app[web.1]:
2016-10-13T21:51:16.859872+00:00 app[web.1]: ActionView::Template::Error (PG::UndefinedTable: ERROR: relation "trainers" does not exist
2016-10-13T21:51:16.859873+00:00 app[web.1]: LINE 1: SELECT "trainers".* FROM "trainers"
2016-10-13T21:51:16.859874+00:00 app[web.1]: ^
2016-10-13T21:51:16.859874+00:00 app[web.1]: : SELECT "trainers".* FROM "trainers"):
2016-10-13T21:51:16.859875+00:00 app[web.1]: 51:
2016-10-13T21:51:16.859876+00:00 app[web.1]: 52:
2016-10-13T21:51:16.859877+00:00 app[web.1]: 53: <tbody>
2016-10-13T21:51:16.859877+00:00 app[web.1]: 54: <% @trainer.each do |trainer| %>
2016-10-13T21:51:16.859878+00:00 app[web.1]: 55: <tr class="<%= cycle('oddline', 'evenline') %>">
2016-10-13T21:51:16.859879+00:00 app[web.1]: 56: <td><%= trainer.pname %></td>
2016-10-13T21:51:16.859880+00:00 app[web.1]: 57: <td><%= trainer.level %></td>
2016-10-13T21:51:16.859881+00:00 app[web.1]: app/views/welcome/index.erb:54:in `_app_views_welcome_index_erb__3990380873615253162_69847032979680'
2016-10-13T21:51:16.859882+00:00 app[web.1]:
2016-10-13T21:51:16.859882+00:00 app[web.1]:
가 trainers_controller.rb 여기
class TrainersController < ApplicationController
before_action :set_trainer, only: [:show, :edit, :update, :destroy]
# GET /trainers
# GET /trainers.json
def index
@trainer = Trainer.all
end
의 일부이다
class WelcomeController < ApplicationController
# GET /welcome
def index
@trainer = Trainer.all
end
end
당신은 heroku가 테이블을 만들기 위해 데이터베이스를 긁어 야합니다. 당신이 heroku cli를 운영한다면'heroku run rake db : migrate' – teddybear
안녕하세요. 기본적으로 데이터베이스에 강사 테이블이 없기 때문에 마이 그 레이션 (또는 스키마)을 확인하는 것을 잊어 버린 것 같아요. –
감사합니다. 나는 그것을 시도 할 것이다. 그건 그렇고, 레일을 사용하여 : scaffold Trainer pname : string ******을 생성하여 테이블을 만듭니다. 그러나 트레이너를 사용할 때, 트레이너와 트레이너는 나를 혼란스럽게 만듭니다. 당신이 나를 도울 수? –